A powerful command-line tool for creating and running Go WebAssembly applications with hot reload capabilities.
- π Quick App Creation: Generate new Go WebAssembly applications with a single command
- π₯ Hot Reload: Automatic recompilation and browser refresh on file changes
- π Web Server: Built-in development server with WebSocket support
- π¦ Cross-Platform: Support for Windows, macOS, and Linux (AMD64 and ARM64)
- π§ VS Code Integration: Automatic workspace configuration for optimal development experience
- π± Responsive Development: Live reload across local and network devices
Run the installation script:
curl -fsSL https://raw.githubusercontent.com/gofred-io/gofred-cli/refs/heads/master/install.sh | bashThis script will:
- Detect your operating system and architecture
- Download the appropriate binary
- Install it to
~/.local/bin(or~/AppData/Local/binon Windows) - Add the directory to your PATH if needed
- Download the appropriate binary for your platform from the releases page
- Extract the binary to a directory in your PATH
- Make it executable (on Unix systems):
chmod +x gofred
gofred versionCreate a new Go WebAssembly application:
gofred app create my-app --package my-appOptions:
path: Path where to create the application (required, positional argument)--package, -p: Package name for the application (default: "gofred-app")
Example:
gofred app create hello-world --package hello-worldThis will create:
- A
main.gofile with a basic "Hello, world" application - A
web/folder with necessary HTML, CSS, and JavaScript files - A
.vscode/settings.jsonfile configured for Go WebAssembly development - A
go.modfile initialized with the specified package name
Navigate to your application directory and start the development server:
cd my-app
gofred app runThis will:
- Compile your Go code to WebAssembly
- Start a development server (usually on
http://localhost:PORT) - Open your browser automatically
- Watch for file changes and automatically recompile and reload
gofred --help # Show help information
gofred version # Show version information
gofred update # Update to the latest version
gofred app create <path> [flags] # Create a new application
gofred app run # Run the application (must be in app directory)--offline, -o: Run in offline mode (uses embedded web assets instead of downloading from CDN)
- Create your app:
gofred app create my-app --package my-app - Navigate to the directory:
cd my-app - Start development:
gofred app run - Edit your code: Modify
main.goor other.gofiles - See changes instantly: The app automatically recompiles and reloads in your browser
When you create a new application, the following structure is generated:
my-app/
βββ main.go # Your main application file
βββ go.mod # Go module file
βββ web/ # Web assets
β βββ index.html # Main HTML file
β βββ index.css # Styles
β βββ index.js # JavaScript runtime
β βββ wasm_exec.js # WebAssembly execution helper
β βββ env.js # Environment configuration (auto-generated)
βββ .vscode/ # VS Code configuration
β βββ settings.json # Go WebAssembly settings
βββ web/main.wasm # Compiled WebAssembly binary (auto-generated)
The generated main.go file contains a simple example:
package main
import (
"github.com/gofred-io/gofred/foundation/text"
"github.com/gofred-io/gofred/application"
)
func main() {
app := text.New("Hello, world")
application.Run(app)
}- Go 1.25.1 or later
- A modern web browser that supports WebAssembly
- For installation:
curl,tar, andjq(automatically installed by the install script)
- Permission denied: Make sure the installation directory is writable
- Command not found: Ensure the binary directory is in your PATH
- Download failed: Check your internet connection and try again
- Compilation errors: Check your Go code for syntax errors
- Browser not opening: Manually navigate to the URL shown in the terminal
- Hot reload not working: Ensure you're running the command from within your app directory
If you're having network issues, you can run in offline mode:
gofred app create my-app --package my-app --offline
gofred app run --offlineContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please:
- Check the troubleshooting section above
- Search existing GitHub Issues
- Create a new issue with detailed information about your problem
Happy coding with Gofred! π