Member-only story
Create Go service the easy way
For Windows, Linux, MacOS and Docker

- part: you are reading it right now
- part: improving the service
- part: upgrade for web
- part: adding SSE
- part: simple javascript frontend functionality
- part: frontend — backend communication
- part: server-side logging
- part: run it all in docker
- part: adding database container
- part: database — service communication
Addition 1: functions, methods, pointers and interfaces
Addition 2: websocket communication
Addition 3: socket communication
Why would you want to create a service?
With Go programming language you can use the final executable the same way on Windows, Linux and MacOS (by generating proper executable). But you cannot install this executable as a service using standard system tools like sc.exe
, systemd
or launchd
. By using this approach you will know, how to make your software executable installable with those system tools and make it run as a service, when system starts.
As a bonus, this approach also works for Docker containers.
Prepare the project
I assume you have some knowledge of Go language, and programming in general. But you can use this article as an easy preview what — and how — can be done with Go programming language.
In this article, we will be using GoLand. Let’s get it started.
Start up Goland and create a new project using Go modules. Name the project medium_service
and hit Create.

In the project window, create new Go File and name it main.go
. Then select type of Simple application.