As a web developer learning another skill just to make a desktop app is time consuming. There are a few go packages which help you build a desktop ui using html/css/js. I found are wails.io, gioui and other packages very interesting. But, since I've already build a web app in Fiber I looked for a way to use the same code in the desktop app.
I created fiberwebgui to solve this issue.
This small package just starts the Fiber server and the Chrome* browser in app mode. Doing this allows you to use Fiber go web framework to create a desktop application using html/css/js, go html templates, vue, react etc anything you would use to create a website.
Install
go get -u github.com/ClimenteA/fiberwebgui
Usage
package main
import (
"github.com/ClimenteA/fiberwebgui"
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World 👋!")
})
fiberwebgui.Run(app)
// or initial width/height
// fiberwebgui.RunWithSize(app, 800, 600)
}
Distribution
Here are some CLI go commands for cross-platform executables.
Windows 64bit:
GOOS=windows GOARCH=amd64 go build -ldflags -H=windowsgui -o dist/myapp.exe main.go
Linux 64bit:
GOOS=linux GOARCH=amd64 go build -o dist/myapp main.go
Mac 64bit:
GOOS=darwin GOARCH=amd64 go build -o dist/myapp main.go
Of course, modify these commands as needed for your specific hardware.
The source code can be adapted to be used with other go web frameworks, just fork it and modify as needed.
You can find the source code here: https://github.com/ClimenteA/fiberwebgui.
Top comments (0)