# How to put a Go app online

https://netrun.io/en/blog/go-prilozhenie

_October 5, 2026 · 3 min read_

> To put a Go app online, upload the source code with its go.mod file and listen on the port from the PORT environment variable — there is no need to build the binary yourself. Netrun recognizes Go by go.mod, downloads the dependencies, builds the project and gives you an HTTPS link. The app reads keys and the database connection string with os.Getenv from secrets you set in the dashboard.

- A go.mod file in the project root tells Netrun the project is a Go app and lists the dependencies for the build.
- A Go service should listen on the port from the PORT environment variable, read with os.Getenv("PORT").
- In Go, an address like ":"+port means listening on all addresses, while a server bound to "127.0.0.1" is unreachable from outside.
- There is no need to build the binary locally or install Go on a server: Netrun builds the project from source.
- Netrun stores secrets encrypted and passes them to the app as environment variables.

Normally, to show a Go app to the world you have to rent a server, build the binary on it, put nginx next to it as a proxy, get an SSL certificate, and make sure the process does not crash. Go is convenient because the whole project compiles into a single executable file, but the fuss around the server does not go away because of that.

Netrun removes that part: you upload your source code, we see for ourselves that it is Go, build the project, and give you a public link with HTTPS (a secure connection, the padlock in the browser). No server, no nginx, no manual certificate — below is how to get from a folder of code to a working link.

## 1. Check that there is a go.mod in the root

The go.mod file in the project root lists dependencies and tells Netrun that this is a Go app. You do not need to include the dependencies folder (for example, vendor) — we will pull the libraries in ourselves from go.mod during the build.

## 2. Read the port from the environment variable

If you have a web service, it should listen on the port that Netrun sets through the PORT environment variable, not one hard-coded in the code. In practice this means taking the port via os.Getenv("PORT") and listening on exactly that — then we automatically expose the right address to the outside. A hard-coded port would break publishing.

## 3. Upload your code

Open Netrun and bring your project in one of two ways: as a ZIP archive with the sources, or by importing from a GitHub repository, including a private one. The code with go.mod is enough — you do not need to build the binary yourself or install Go anywhere, it all happens on our side.

## 4. Add secrets if you have any

If your app talks to an external service or a database, we will ask for API keys, tokens, and the connection string during setup. They will be placed into environment variables and will not sit in the code — read them from the environment with os.Getenv, the same way as the port.

## 5. Wait for the build and grab the link

Netrun builds the project and brings it up on its own. Logs and publishing status are visible in your dashboard in real time, so you will notice right away if something goes wrong. When everything is ready, you get a public link with HTTPS — you can open it and send it to anyone.

That is it: your Go app is available on the internet without renting a server or setting up SSL. On the Free plan you get one project, and a web service on it sleeps when idle and wakes on request — the first response after a pause will be a little slower. If your app needs to respond without delays around the clock, a paid plan with no idle downtime is a good fit, and if you need more projects, you can pay for extra ones. [Try Netrun](https://netrun.io/).

Similar guides: [a Node.js app](https://netrun.io/blog/nodejs-prilozhenie), [Netrun, VPS or Heroku: which to choose](https://netrun.io/blog/kak-vybrat-netrun-vps-heroku).

## Common questions

### How do I read the port correctly in Go?

Take it from the environment: port := os.Getenv("PORT"), then start the server with http.ListenAndServe(":"+port, handler). The colon with no address means "listen on all addresses", which is exactly what you want. For local runs, fall back to a default value when the variable is empty.

### Do I need to include the vendor folder in the archive?

No. Dependencies are fetched during the build from go.mod and go.sum, so the source code is enough. Keep go.sum up to date: without the right entries in it, the build can stop at the dependency check.

### Can I publish a Go program that is not a web server, such as a bot?

Yes. If the program does not listen on a port, Netrun runs it as a background process with no public link — that is how bots and scripts work. On the Free plan such a project runs for a limited time; around the clock takes the Pro plan.

### Why does my Go site sometimes take a moment to open?

On the Free plan a web service sleeps without visitors and wakes on the first request, so the first load after a pause takes a few seconds. On the Pro plan the project does not sleep and answers right away.

### Where should a Go app keep files and an SQLite database?

In the persistent /data folder: whatever the app writes there survives code updates and restarts. Files outside /data disappear on the next publish.
