Inquir Compute · Go

Go 1.22 serverless functions with isolated runtimes

Deploy Go 1.22 functions as isolated serverless containers: export a Handler(event, context) entry point like AWS Lambda, use go.mod for dependencies including CGO packages, and share gateway routing with Node.js and Python functions in the same workspace.

Last updated: 2026-06-28

Direct answer

Go 1.22 serverless functions with isolated runtimes. Inquir Go functions export Handler(event, context)—the same event-map contract as Node.js and Python on the platform. Parse gateway HTTP fields from event["body"], event["headers"], and event["queryStringParameters"]; return a map or API Gateway-style object. CGO packages compile at deploy because functions run in full Docker-based containers.

When it fits

  • High-throughput JSON handlers where Go allocation efficiency matters
  • Functions that depend on CGO packages (SQLite, image processing, crypto)
  • Teams already writing Go services who want consistent language across the stack

Tradeoffs

  • Edge runtimes run in V8 isolates—no CGO, no native modules, no system packages. SQLite bindings, image processing libraries, and crypto packages that depend on C are simply not available.
  • Lambda Go runtime requires compiling a main binary with a custom handler signature and bootstrap shim—not the same event map you use for Node.js and Python on the same API.

Why Go serverless was painful before

  • Edge isolates do not support CGO or native system libraries
  • AWS Lambda Go requires a custom bootstrap binary and non-standard handler wiring
  • Mixing Go functions with Node.js or Python APIs meant separate platforms or Lambda layer hacks

Go is ideal for high-throughput handlers, CLI tools compiled into functions, and computationally heavy work that benefits from static typing and goroutines. But standard serverless platforms treat Go as a second-class citizen—requiring bootstrap wrappers, excluding CGO, or forcing you off the platform entirely.

What you lose on edge or Lambda Go runtimes

Edge runtimes run in V8 isolates—no CGO, no native modules, no system packages. SQLite bindings, image processing libraries, and crypto packages that depend on C are simply not available.

Lambda Go runtime requires compiling a main binary with a custom handler signature and bootstrap shim—not the same event map you use for Node.js and Python on the same API.

Lambda-compatible Go handlers in isolated containers

Inquir Go functions export Handler(event, context)—the same event-map contract as Node.js and Python on the platform. Parse gateway HTTP fields from event["body"], event["headers"], and event["queryStringParameters"]; return a map or API Gateway-style object. CGO packages compile at deploy because functions run in full Docker-based containers.

Go functions share the API gateway with Node.js and Python functions in the same workspace. One routing table, one secrets model, one observability stack—regardless of language.

Go 1.22 serverless function features

Lambda-compatible handler contract

Export Handler(event map, context map) (or obs.Context). No custom bootstrap binary or net/http server wrapper required.

Full Go module ecosystem

go.mod and go.sum included. CGO-dependent packages like mattn/go-sqlite3 compile during deploy in container builds.

Goroutine-safe concurrency

Go goroutines work as expected. Fan out concurrent requests, use channels, and leverage Go native concurrency primitives.

Polyglot workspace

Go functions share gateway routes, secrets, and observability with Node.js and Python functions in the same workspace.

How to deploy Go serverless functions on Inquir

1

Write a Handler entry point

Export func Handler(event map[string]interface{}, ctx map[string]interface{}) (interface{}, error). Parse string event["body"] for gateway JSON POSTs.

2

Define go.mod

Standard Go module file. List dependencies including CGO packages if needed.

3

Deploy and route

Inquir compiles the plugin, deploys the function, and adds it to gateway routing alongside other language functions.

Go serverless function: JSON API handler

Lambda-compatible pattern. Parse event["body"] when the gateway sends a JSON string; return statusCode + body for HTTP routes. CGO dependencies in go.mod compile at deploy.

handler.go
package main

import (
	"encoding/json"
)

func parsePayload(event map[string]interface{}) map[string]interface{} {
	if s, ok := event["body"].(string); ok && s != "" {
		var out map[string]interface{}
		if err := json.Unmarshal([]byte(s), &out); err != nil || out == nil {
			return map[string]interface{}{}
		}
		return out
	}
	return event
}

func Handler(event map[string]interface{}, ctx map[string]interface{}) (interface{}, error) {
	payload := parsePayload(event)
	name, _ := payload["name"].(string)
	if name == "" {
		name = "World"
	}
	body, _ := json.Marshal(map[string]string{"message": "Hello, " + name})
	return map[string]interface{}{
		"statusCode": 200,
		"headers":    map[string]interface{}{"Content-Type": "application/json"},
		"body":       string(body),
	}, nil
}

Use Go serverless functions for

When this works

  • High-throughput JSON handlers where Go allocation efficiency matters
  • Functions that depend on CGO packages (SQLite, image processing, crypto)
  • Teams already writing Go services who want consistent language across the stack

When to skip it

  • Heavy ML/data processing—Python with numpy/pandas is better suited for that use case

FAQ

Does CGO work in Inquir Go functions?

Yes. Functions run in full Docker-based containers with a real Linux build environment—CGO packages in go.mod build at deploy, unlike edge runtimes.

Is this net/http or Lambda-style?

Lambda-style: export Handler(event, context) and parse gateway fields from the event map. You do not write an http.ListenAndServe server—the platform invokes Handler per request.

How does cold start compare to Node.js?

Go binaries typically start faster than Node.js for the same workload. Use hot containers for steady traffic patterns regardless of language for consistent p95 latency.