At a glance
What Enzonic Deploy does with a Go project when you connect it. You can override any of it in the project settings.
- Language
- Go
- Detected from
- go.mod at the project root
- Build command
- go build -o .enzonic/bin/server . (or ./cmd/<name>)
- Output
- .enzonic/bin/server
- Runs as
- Server
How it runs
Server
Always: the binary is started with PORT set.
Deploy Go step by step
- 1Listen on the PORT environment variable.
- 2Keep -o .enzonic/bin/server if you override the build command.
- 3Connect the repository and deploy.
main.go
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello from Go on Enzonic")
})
http.ListenAndServe(":"+port, nil)
}Connect a database to Go
Create a database on Enzonic Databases (or from the project's settings) and its connection string is added to the project's environment variables. This example uses PostgreSQL.
db.go
pool, err := pgxpool.New(ctx, os.Getenv("DATABASE_URL"))
if err != nil {
log.Fatal(err)
}
defer pool.Close()
var now time.Time
err = pool.QueryRow(ctx, "select now()").Scan(&now)Postgres projects get two variables: DATABASE_URL through the connection pooler for the app, and DATABASE_URL_UNPOOLED for migrations.
PostgreSQL on Enzonic DatabasesEvery database engineThings to know
- The binary must be static: cgo is off (CGO_ENABLED=0), so packages that need a C library will not build.
- A custom build command that drops -o .enzonic/bin/server fails with a message saying so.
Plan limits that matter here
From the live plan data. Every plan includes previews for each branch, instant rollback, environment variables and logs.
| Limit | Free | Pro |
|---|---|---|
| Build minutes | 3,000/mo, 1 concurrent | 10,000/mo, 3 concurrent |
| Servers | 1 instance, 512 MB, sleeps after 15 min idle | 3 always-on, 2 GB |
| Bandwidth | 150 GB/mo | 2 TB/mo |
Related guides
- Deploy a Node.js appAny Node.js server with a start script: bots, WebSocket servers, workers with an HTTP port.
- Deploy a FastAPI appFastAPI (and Starlette) apps as ASGI functions on Python 3.12.
- Deploy a NestJS appNestJS APIs compiled with nest build and started from dist/main.js.
Ship your Go project tonight
Connect the repository and the build settings fill themselves in. Free plan, no card.