Quick Start — Go¶
Deploy a Go app from git push to a live HTTPS URL in 5 minutes.
Prerequisites¶
- A Go project with a
go.modandmain.go - Go 1.21+ on your machine (
go version) - The
paasCLI:
If you don't already have a Go project, scaffold one:
mkdir hello-paas && cd hello-paas
go mod init hello-paas
cat > main.go <<'EOF'
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintln(w, "Hello from PaaS Runtime!")
})
fmt.Println("listening on :" + port)
if err := http.ListenAndServe(":"+port, nil); err != nil {
panic(err)
}
}
EOF
git init && git add -A && git commit -m "init"
Step 1 — Authenticate¶
Verify:
Step 2 — Create the app¶
Output:
✓ Created app hello-paas
URL: https://hello-paas.runtime.di2amp.com
Region: eu-fr-1
Plan: free
Git: https://git.di2amp.com/octave/hello-paas.git
Step 3 — Add a Procfile¶
The Paketo Go buildpack auto-detects main.go and builds a static binary. You only need to declare process types:
Commit:
Step 4 — Push to deploy¶
You'll see live build logs:
remote: ─────── PaaS Build ───────
remote: → Detected: go (paketo-buildpacks/go)
remote: → Installing Go 1.22.0
remote: → Running: go build -o /workspace/hello-paas .
remote: → Image: registry.di2amp.com/octave/hello-paas:abc1234
remote: → Image size: 12 MB (static binary, distroless base)
remote: → SBOM: ✓ generated, 8 packages
remote: → CVE scan: ✓ 0 critical, 0 high
remote:
remote: ─────── PaaS Deploy ───────
remote: → Process types: web
remote: → Replicas: 1/1 ready
remote: → Rollout: v1 → v2 (canary 10% → 100%)
remote: → Health: / returns 200 OK
remote: → URL: https://hello-paas.runtime.di2amp.com
remote:
remote: ✓ Deployed in 28s
The Go buildpack produces compact images (~10–20 MB) thanks to static binaries on a distroless base.
Step 5 — Verify the app is live¶
Dashboard runtime status:
https://ma30.di2amp.com/runtime/dashboard/apps/hello-paas
Next steps¶
Add a managed PostgreSQL¶
DATABASE_URL is injected:
import "database/sql"
import _ "github.com/jackc/pgx/v5/stdlib"
db, err := sql.Open("pgx", os.Getenv("DATABASE_URL"))
Tail logs¶
Custom build flags¶
The Paketo Go buildpack reads BP_GO_BUILD_FLAGS and BP_GO_TARGETS:
Multi-binary¶
Build two binaries (web + worker) by setting:
Then in Procfile: