Go is increasingly popular among Uzbekistan's backend developers for its performance, simplicity, and small binary size. if.uz supports Go out of the box — Nixpacks detects your go.mod file, compiles the binary, and runs it. No Dockerfile, no manual build steps.
Project Structure
my-go-app/
├── main.go
├── go.mod
├── go.sum
└── ... ← any additional packagesStep 1 — main.go
The critical requirement: read the PORT from the environment. if.uz injects this at runtime.
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello from if.uz!")
})
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
fmt.Fprintln(w, `{"status":"ok"}`)
})
log.Printf("Server starting on port %s", port)
log.Fatal(http.ListenAndServe(":"+port, nil))
}Step 2 — go.mod
module github.com/yourusername/my-go-app
go 1.22ℹ️ Info
Nixpacks detects Go 1.22 or the version specified in your go.mod "go" directive. Any Go version ≥ 1.18 is supported.
Step 3 — Deploy on if.uz
- 1Push your code to GitHub
- 2Open if.uz dashboard → "Deploy new app"
- 3Select your Go repo and branch
- 4Click Deploy
Nixpacks runs go build -o app . and then executes the compiled binary. The build is fast (~30 seconds for most Go projects) and the binary starts almost instantly.
Using a Popular Go Framework (Gin / Fiber / Echo)
Gin Example
package main
import (
"net/http"
"os"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "Hello from if.uz!"})
})
r.GET("/health", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "ok"})
})
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
r.Run(":" + port)
}Connecting to Postgres
Deploy a PostgreSQL instance from the Marketplace, then read DATABASE_URL in your Go app:
import (
"database/sql"
"os"
_ "github.com/lib/pq"
)
func initDB() *sql.DB {
dbURL := os.Getenv("DATABASE_URL")
db, err := sql.Open("postgres", dbURL)
if err != nil {
log.Fatal("Failed to connect to DB:", err)
}
return db
}Environment Variables
DATABASE_URL=postgresql://postgres:[email protected]:5432/mydb
APP_ENV=production
JWT_SECRET=your-secret-hereWhy Go + if.uz is a Great Combination
- Go binaries start in milliseconds — almost no cold-start delay
- Tiny memory footprint — a typical Go API uses 10–30 MB RAM (well within the free plan's 256 MB)
- if.uz's local infrastructure means your Uzbek users get responses in < 30ms
- No Dockerfile needed — Nixpacks compiles and runs Go automatically
Go is one of the most efficient languages to run on if.uz's free plan. A Go API serving hundreds of requests per second easily fits in 256 MB RAM with 0.25 vCPU. Sign up at if.uz and deploy your Go app for free today.