The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Follow publication

Create Go service the easy way

For Windows, Linux, MacOS and Docker

Petr Jahoda
The Startup
Published in
5 min readDec 17, 2020
Original Gopher image created by Renee French, used Gopher image created by Maria Letta
  1. part: you are reading it right now
  2. part: improving the service
  3. part: upgrade for web
  4. part: adding SSE
  5. part: simple javascript frontend functionality
  6. part: frontend — backend communication
  7. part: server-side logging
  8. part: run it all in docker
  9. part: adding database container
  10. 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.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Petr Jahoda
Petr Jahoda

Written by Petr Jahoda

Love programming, math, running and piano

Responses (3)

Write a response