Web application in Golang for offline/browser use


I’d like to create a simple web application to manage some data. The application will use PostgreSQL but I have no idea how to package everything in order to make it run on windows, linux, and mac. I can cross-compile a go binary which will include everything (web server, etc..) but the postgresql database will be left out because that’s running as a separate server locally. I heard about docker but I don’t know if that’s the right solution.

Should I create a docker container and include PostgreSQL in it so I can start that web app on any platform?


You don’t need Docker to do this.

It complicates things since your users will have to install the Docker engine first. Go is perfectly capable for cross platform applications, batteries included.

Decide if you want your app to run in a browser tab or should it have it’s own window?

For a browser tab compile your app for the target architecture and think about a URL scheme that will make sense to your users, for example

  • localhost:8080/app => the user interface. This route is the web app, it serves HTML, JS and CSS. Tell your users to run the executable (or install it as a service, see this or use a platform specific tool like this one). Then open the link in a browser
  • localhost:8080/api => backend routes. Serves data to requests made by the user interface. For talking to the Postgres server running locally

If you want your app to run in it’s own window have a look at Electron. See gotron: Go Api for Electron

Answered By – mozey

Answer Checked By – Mildred Charles (GoLangFix Admin)

Leave a Reply

Your email address will not be published.