Revived HTA with Go and Chrome
- Build desktop-like apps easily from HTML, similar to HTA.
- When you need more capability, extend it with Go.
To enable live reload functionality during development, run with the dev tag:
go run -tags dev . your-file.html- File Watching: Automatically watches for changes in HTML, CSS, JS, JSON, and XML files
- WebSocket Live Reload: Establishes WebSocket connection for real-time communication
- Automatic Browser Refresh: Browser automatically refreshes when files are modified
- Debounced Updates: Prevents multiple rapid reloads when multiple files change
# Build in development mode
go build -tags dev
# Run with your HTML file
./gohta your-file.htmlThe browser will automatically refresh whenever you save changes to your HTML, CSS, or JavaScript files.
gohta can also run as a self-contained application. By placing your entire website (including index.html, CSS, images, etc.) into a static directory, gohta will automatically embed these files into the executable at build time.
- Create a
staticDirectory: Place all your web assets in a directory namedstaticat the root of the project. - Automatic Detection: When the application starts, it checks for the existence of a
static/index.htmlfile within the embedded assets. - Self-Contained Serving: If
static/index.htmlis found,gohtaswitches to "self-contained mode" and serves all content from the embeddedstaticdirectory. It will no longer require a file path argument.
To build a self-contained application with your site embedded:
# Place your site in the 'static' directory
echo "<h1>Hello from self-contained mode!</h1>" > static/index.html
# Build the application
go build
# Run the self-contained app
./gohtaThe application will now serve your index.html and all other assets from the static directory, completely from within the executable.
On Windows, you can choose whether the app shows a console window.
- With console (default):
# Shows console window (useful for logs)
go build- Without console (hide console window):
# Build a GUI executable without a console window
go build -ldflags "-H=windowsgui"