templ is a great view framework but there is no clear documentation (as of writing) showing how to use it with the Echo web framework. This short guide should show you how to set it up:
Install templ and echo:
go get github.com/a-h/templ
Below are a small collection of React examples to get anyone started using React. They progress from simpler to more complex/full featured.
They will hopefully get you over the initial learning curve of the hard parts of React (JSX, props vs. state, lifecycle events, etc).
You will want to create an index.html
file and copy/paste the contents of 1-base.html
and then create a scripts.js
file and copy/paste the contents of one of the examples into it.
Want to release a new binary on Github for every new git tag (e.g. v1.2.7
)? Here is a simple Github Actions yaml config file that should get you started.
This script will automatically checkout your code, setup the correct version of go as defined in your go.mod
file
and build your go binary (in this case using a Makefile
default target), then upload it to a new Github Release.
# .github/workflows/release.yml
name: Build and release Go Project
If you want to run your own app on a Debian system, like a RaspberryPi, you'll need to build the binary for the given device then setup systemd to run the binary.
Given you have an app called myapp
, first create a service file to run your app, say at myapp.service
on your local system:
[Unit]
Description=Some description here...
After=network.target
For a project I'm working on, I need to ship a single server binary with all static files embedded and use that for the frontend of the server. The backend has a variety of routes which the frontend calls.
The frontend is a SvelteKit static app built to ./frontend/build
. Here is the
Echo configuration to get these files serving at the root of the web server:
On Android devices, if you want to create a file input that prompts the
user to either choose an image from their photo album or take a picture with their
camera, you'll need this basically undocumented capture
attribute added to your input's accept
property:
<input type="file" accept="image/*;capture=camera" />
await run(); | |
async function run() { | |
let loop = 0; | |
while (true) { | |
loop++; | |
console.log("loop:", loop); | |
const items = get_items(); | |
if (!items.length) break; |
var fs = require('fs'); | |
var PDFDocument = require('pdfkit'); | |
var pdf = new PDFDocument({ | |
size: 'LEGAL', // See other page sizes here: https://github.com/devongovett/pdfkit/blob/d95b826475dd325fb29ef007a9c1bf7a527e9808/lib/page.coffee#L69 | |
info: { | |
Title: 'Tile of File Here', | |
Author: 'Some Author', | |
} | |
}); |