DEV Community

Alin Climente
Alin Climente

Posted on • Edited on

Create cross-platform desktop apps using Fiber and GO!

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
Enter fullscreen mode Exit fullscreen mode

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)
}

Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Linux 64bit:

GOOS=linux GOARCH=amd64 go build -o dist/myapp main.go
Enter fullscreen mode Exit fullscreen mode

Mac 64bit:

GOOS=darwin GOARCH=amd64 go build -o dist/myapp main.go
Enter fullscreen mode Exit fullscreen mode

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay