Deploy Go App

All projects based on Go Modules (opens in a new tab) can be deployed. But you need to have a main.go in the project root directory as the program compilation entry.

If you have multiple program compilation entries, you need to put them in the cmd directory, for example, a cmd/server-a/main.go and a cmd/server-b/main.go.

Zeabur will automatically recognize and deploy the program compilation entry with the same Service name under the cmd directory.

Listen on Port

Zeabur will automatically set the PORT environment variable for the Go program to listen on.

port := os.Getenv("PORT")
if port == "" {
    port = "8080"
http.ListenAndServe(":"+port, nil)

Serverless Support

Zeabur supports deploying Go as a serverless project. However, it currently requires opt-in. Please refer to the Enable Serverless page to enable serverless support.