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.modat 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
PORTto match. -
The database. If your code needs Postgres, Antideploy creates one and sets
DATABASE_URLand thePG*variables.
A small Go server
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
-
Check the module
go.modandgo.sumare committed. Rungo mod tidyif you added a package. -
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
.envwithout printing them. -
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 entryorupdates to go.mod needed. Rungo mod tidyon your machine and commitgo.modandgo.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. ReadPORTand listen on all addresses. See never started listening.