Skip to main content

Deploy Go Apps

Go is a popular programming language for backend development. Go is served as a compiled language, which means you need to compile your code before running it. This is different from interpreted languages like PHP, Python, and Ruby.

Popular Go recipes include Gin and Echo. Please read our Runner's Guide first if you haven't.

Recipes

Init

source: clear
features:
- go latest
nginx:
root: public_html/public
passenger:
enabled: on
app_start_command: env PORT=$PORT ./app
commands:
- go mod init app
- go get github.com/gin-gonic/gin
- filename: app.go
content: |
package main

import "github.com/gin-gonic/gin"

func main() {
app := gin.Default()
app.GET("/", func(c *gin.Context) {
c.String(200, "Hello, World!")
})
app.Run()
}
- go build -o app

A simple Go website with Gin for development.

Go Environment

You can specify the Go version in the features section. For example, go 1.16.5 will install Go 1.16.5. You can also use go latest to install the latest version of Go.

features:
- go latest

There are no builtin Go compiler in system files. You need to install Go first before using it.