Skip to content
tako
Esc
↑↓navigate↵open⌘Jpreview
On this page

Go net/http

Serve a Go http.Handler with Tako's listener, authenticated status endpoint, bootstrap secrets, and native build configuration for deployment.

The root Go module is tako.sh. Its ListenAndServe accepts any http.Handler, including the standard library router and Gin, Echo, or Chi routers.

Connect the handler

go get tako.sh
package main

import (
    "fmt"
    "log"
    "net/http"

    "tako.sh"
)

func main() {
    mux := http.NewServeMux()
    mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintln(w, "Hello from Tako")
    })
    if err := tako.ListenAndServe(mux); err != nil {
        log.Fatal(err)
    }
}

Tako owns the listening address, readiness signal, authenticated internal /status, and graceful shutdown. For a custom server loop use tako.Listener() and retain internal status handling; see the Go SDK skill.

Configure and verify

name = "go-app"
runtime = "go"
main = "app"

[build]
run = "CGO_ENABLED=0 go build -o app ."

[envs.production]
route = "go.example.com"
servers = ["prod"]

Use the CGO setting appropriate to your dependencies. Build for the selected server’s OS/architecture; copying a macOS binary does not produce a Linux release. See Deployment for build/artifact behavior and Docker for server-side image builds.

Run go test ./..., start tako dev --background --json, and request the returned HTTPS URL. Set private values with Secrets and run tako generate for typed Go accessors. Presence and Stores have Go backend registrations consumed by the shared browser clients.

Source example: examples/go/basic.

Last updated on

Was this page helpful?