BlogGo

How to deploy a Go app.

A Go app deploys with one sentence. Antideploy builds the binary and runs it, and your code listens on PORT.

How the Agent API works
  • go.modDetected from the file at the root
  • A built binaryThe build sets the entrypoint
  • PORTRead it, default 8080
  • DATABASE_URLSet for you with Postgres

The short answer

To deploy a Go app, give your coding agent the sentence below. Antideploy finds go.mod, builds your program into one binary, and runs it. You do not write a start command. Your code must listen on the port in the PORT variable, and on all addresses. For Go projects, Antideploy uses port 8080.

Say this to your coding agent

Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.

What Antideploy detects

  • Go. Detected from go.mod at the root of what you send.
  • The start command. Antideploy does not add one. Go compiles to a single binary, and the build sets the entrypoint from what it produced.
  • The port. It sends traffic to port 8080 and sets PORT to match.
  • The database. If your code needs Postgres, Antideploy creates one and sets DATABASE_URL and the PG* variables.

A small Go server

main.go
package main

import (
	"context"
	"fmt"
	"net/http"
	"os"

	"github.com/jackc/pgx/v5/pgxpool"
)

func main() {
	port := os.Getenv("PORT")
	if port == "" {
		port = "8080"
	}

	pool, err := pgxpool.New(context.Background(), os.Getenv("DATABASE_URL"))
	if err != nil {
		panic(err)
	}
	defer pool.Close()

	http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprint(w, "ok")
	})

	http.ListenAndServe(":"+port, nil)
}

Listening on ":" + port means all addresses, which is what a server needs. Do not use "localhost:" + port.

Step by step

  1. Check the module

    go.mod and go.sum are committed. Run go mod tidy if you added a package.

  2. Paste the sentence and approve one link

    Your agent creates the app, and a database if your code needs one, and writes the connection details into your .env without printing them.

  3. Deploy and open the link

    Antideploy builds the binary, starts it and checks that it answers. Your agent tells you the address.

Common problems

  • go.sum is incomplete. The build says missing go.sum entry or updates to go.mod needed. Run go mod tidy on your machine and commit go.mod and go.sum.
  • The program does not compile. The deploy names the error, such as an undefined name.
  • The app never starts listening. It uses a fixed port, or localhost. Read PORT and listen on all addresses. See never started listening.

01Before you commit

Here's where it stops.

A platform that only tells you what it is good at is one you find the edges of in production. These are the ones to know before your first deploy.

  1. Apps sleep when idle

    On every plan, an app nobody is using goes to sleep and the next visit wakes it. The first request took 2.9 to 13.9 seconds in our measurements, depending on the stack. There are no always-on workers, so use a cron job or a webhook for background work.

  2. One instance, no previews

    Each app is one instance with 1 shared vCPU and 1 GB of memory, and a Java app gets 1 dedicated vCPU and 2 GB. There are no preview deployments and no per-branch URLs.

  3. The disk forgets

    Anything written to local disk is gone on the next deploy. Apps that speak S3 get a bucket instead.

02Questions

Go questions, answered.

Anything else? Write to us and a person answers.

support@antideploy.com
Do I need a Dockerfile for Go?

No. Antideploy builds it from go.mod. If there is a Dockerfile at the root, it is used.

Is Go free to host here?

It runs on the Free plan: 1 live app with a server and 1 Postgres database, with no card.

Is the first request slow for Go?

Apps sleep when idle, and the first request after sleeping waits for the app to start. A compiled Go binary starts quickly, but we have not measured Go apps, so there is no number to give.

Can I run background goroutines?

Yes, while the app is running. An idle app sleeps and stops them, so use a scheduled job for work that must happen on a schedule.

Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

Start from GitHub or a folder
Prompt copied Paste it into Claude Code, Codex or Cursor and press Enter.