Skip to main content

What is Go on Zerops?

Zerops provides a fully managed Go runtime environment with automatic compilation, built-in module support, and zero-config deployment. Build and deploy high-performance Go applications, APIs, and microservices with enterprise-grade reliability.
Go is a statically typed, compiled high-level programming language designed at Google. Learn more about Go →

Key Features

Latest Go Versions

Support for Go 1.19 through 1.22 with automatic compilation

Automatic Scaling

Horizontal and vertical auto-scaling based on actual resource usage

Go Modules

Built-in Go modules support for dependency management

Static Compilation

Compile to static binaries for maximum performance and minimal runtime overhead

Supported Versions

Zerops supports multiple Go versions:
  • Go 1.22 (Latest)
  • Go 1.21
  • Go 1.20
  • Go 1.19
You can change the major version at any time through the zerops.yaml configuration.

Quick Example

Deploy a Go application in minutes:
project:
  name: my-go-app
services:
  - hostname: app
    type: [email protected]
    minContainers: 1
    maxContainers: 3
    buildFromGit: https://github.com/zeropsio/recipe-go-hello-world@main
    enableSubdomainAccess: true

Runtime Environment

The Go runtime environment includes:
  • Alpine Linux (default) or Ubuntu
  • Selected Go version
  • Go modules support
  • Git utilities
  • Zerops CLI tools

Common Use Cases

Build high-performance REST APIs with the standard library or frameworks like Gin.
zerops:
  - setup: api
    build:
      base: [email protected]
      buildCommands:
        - go mod download
        - go build -o app .
      deployFiles:
        - app
    run:
      start: ./app
      ports:
        - port: 8080
Deploy scalable microservices with gRPC or HTTP.
zerops:
  - setup: service
    build:
      base: [email protected]
      buildCommands:
        - go mod download
        - CGO_ENABLED=0 go build -ldflags=\"-s -w\" -o app cmd/main.go
      deployFiles:
        - app
        - config
    run:
      start: ./app
Build web apps with frameworks like Echo or Fiber.
zerops:
  - setup: web
    build:
      base: [email protected]
      buildCommands:
        - go mod download
        - go build -o app .
      deployFiles:
        - app
        - static
        - templates
    run:
      start: ./app
Deploy background workers and CLI tools.
zerops:
  - setup: worker
    build:
      base: [email protected]
      buildCommands:
        - go mod download
        - go build -o worker cmd/worker/main.go
      deployFiles:
        - worker
    run:
      start: ./worker

Build Process

Standard Build

zerops:
  - setup: app
    build:
      base: [email protected]
      buildCommands:
        - go mod download
        - go build -o app .
      deployFiles:
        - app
      cache: ~/go/pkg/mod

Optimized Build

Create smaller, optimized binaries:
build:
  base: [email protected]
  buildCommands:
    - go mod download
    - CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o app .
  deployFiles:
    - app

Multi-Binary Build

Build multiple binaries in one project:
build:
  base: [email protected]
  buildCommands:
    - go mod download
    - go build -o api cmd/api/main.go
    - go build -o worker cmd/worker/main.go
  deployFiles:
    - api
    - worker

Runtime Configuration

Simple HTTP Server

run:
  start: ./app
  ports:
    - port: 8080
      httpSupport: true

With Custom Arguments

run:
  start: ./app --port=8080 --env=production
  envVariables:
    GO_ENV: production

Health Check

run:
  start: ./app
  healthCheck:
    httpGet:
      port: 8080
      path: /health

Advanced Build Configurations

With CGO Dependencies

build:
  base: [email protected]
  os: ubuntu
  prepareCommands:
    - sudo apt-get update
    - sudo apt-get install -y gcc g++ make
  buildCommands:
    - go mod download
    - CGO_ENABLED=1 go build -o app .
  deployFiles:
    - app

Cross-Platform Build

build:
  base: [email protected]
  buildCommands:
    - go mod download
    - GOOS=linux GOARCH=amd64 go build -o app .
  deployFiles:
    - app

With Build Tags

build:
  buildCommands:
    - go mod download
    - go build -tags=production -o app .

Environment Variables

Set runtime configuration:
run:
  envVariables:
    GO_ENV: production
    PORT: 8080
    LOG_LEVEL: info
Access in Go:
package main

import "os"

func main() {
    env := os.Getenv("GO_ENV")
    port := os.Getenv("PORT")
}

Common Frameworks

Gin Framework

main.go
package main

import (
    "github.com/gin-gonic/gin"
    "os"
)

func main() {
    r := gin.Default()
    
    r.GET("/", func(c *gin.Context) {
        c.JSON(200, gin.H{
            "message": "Hello from Zerops!",
        })
    })
    
    port := os.Getenv("PORT")
    if port == "" {
        port = "8080"
    }
    r.Run(":" + port)
}

Echo Framework

main.go
package main

import (
    "github.com/labstack/echo/v4"
    "net/http"
)

func main() {
    e := echo.New()
    
    e.GET("/", func(c echo.Context) error {
        return c.JSON(http.StatusOK, map[string]string{
            "message": "Hello from Zerops!",
        })
    })
    
    e.Start(":8080")
}

Fiber Framework

main.go
package main

import (
    "github.com/gofiber/fiber/v2"
)

func main() {
    app := fiber.New()
    
    app.Get("/", func(c *fiber.Ctx) error {
        return c.JSON(fiber.Map{
            "message": "Hello from Zerops!",
        })
    })
    
    app.Listen(":8080")
}

Database Integration

PostgreSQL with GORM

import (
    "gorm.io/driver/postgres"
    "gorm.io/gorm"
    "os"
)

func connectDB() (*gorm.DB, error) {
    dsn := fmt.Sprintf(
        "host=%s user=%s password=%s dbname=%s port=5432 sslmode=disable",
        "db",
        os.Getenv("DB_USER"),
        os.Getenv("DB_PASSWORD"),
        os.Getenv("DB_NAME"),
    )
    return gorm.Open(postgres.Open(dsn), &gorm.Config{})
}

Redis Connection

import "github.com/go-redis/redis/v8"

func connectRedis() *redis.Client {
    return redis.NewClient(&redis.Options{
        Addr: "redis:6379",
    })
}

Performance Optimization

Build Cache

Cache Go modules for faster builds:
build:
  cache: ~/go/pkg/mod

Static Binaries

Create fully static binaries:
build:
  buildCommands:
    - go mod download
    - CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-s -w" -o app .

Parallel Builds

build:
  buildCommands:
    - go mod download
    - go build -p 4 -o app .

Next Steps

Quickstart Guide

Deploy your first Go application

Example Projects

Explore Go examples on GitHub

Build docs developers (and LLMs) love