Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

1. Create and deploy a Go hello app

You will see a hello response at / and ok at /health before adding any services.

1. Download and run locally

Download the hello ZIP into a working directory, then open a terminal in that directory:

unzip go-hello.zip
cd go-hello
go mod download
go run . web

Keep it running. In another terminal, curl -fsS http://localhost:3000/health should print ok. Open http://localhost:3000/ and confirm the hello message. Stop the server with Ctrl+C.

The app source is small enough to inspect in full:

go.mod

module example.com/hello

go 1.27.1

Procfile

web: hello

main.go

package main
import ("fmt"; "log"; "net/http"; "os"; "time")
func main() {
 port:=os.Getenv("PORT"); if port=="" {port="3000"}
 mux:=http.NewServeMux()
 mux.HandleFunc("/",func(w http.ResponseWriter,r *http.Request){fmt.Fprintln(w,"Hello from Go on d2o!")})
 mux.HandleFunc("/health",func(w http.ResponseWriter,r *http.Request){fmt.Fprintln(w,"ok")})
 server:=&http.Server{Addr:"0.0.0.0:"+port,Handler:mux,ReadHeaderTimeout:5*time.Second}
 log.Fatal(server.ListenAndServe())
}

Keep the supplied lockfiles in Git. The buildpack uses these manifests and its runtime version declaration to reproduce the app’s dependencies.

2. Create the Environment

Dashboard: open Project Examples → create Environment go, type Development, branch main, release source Build, Automatic deployment on.

CLI:

paas envs create go -o "$TUTORIAL_ORG" -p examples --type development --branch main --release-source build

3. Create the web app

Dashboard: inside go choose Add Resource → Web Application. Name it notes-web, choose Framework Go, Repository The environment’s shared repository, Directory blank (repository root), and Process type web. Use Port 3000, Health Check Path /health, and one replica. Click Create Resource.

CLI:

paas apps create notes-web --framework go --shared-source --start-command web --port 3000 --health-check-path /health -o "$TUTORIAL_ORG" -p examples -e go

4. Commit and push

Initialize a repository in the unpacked hello directory:

git init -b main
git add .
git commit -m "Add hello application"

Dashboard path: open the Environment’s Git remote panel, copy its shared-repository remote command into this directory, then run its push command. This is the Environment remote, not a per-app remote. The dashboard supplies the correct host and authentication URL.

CLI path: omit -a when setting the shared remote:

paas git remote -o "$TUTORIAL_ORG" -p examples -e go
git push d2o main
paas watch -a notes-web -o "$TUTORIAL_ORG" -p examples -e go

5. Verify the deployed app

Dashboard: open notes-web → Deployments, wait for the successful build and running instance, then open its public URL. Append /health; it should display ok. CLI: paas ps and paas logs with -o "$TUTORIAL_ORG" -p examples -e go and -a notes-web show the running process. Use the public URL displayed in the dashboard, or read the url field from paas apps info notes-web --json with the same Organization, Project, and Environment flags.

APP_URL=https://your-app-host
curl -fsS "$APP_URL/health"
curl -fsS "$APP_URL/"

Set APP_URL to your actual URL, with no trailing slash. If the build fails, see troubleshooting before continuing.

Next: Persist notes in PostgreSQL.