7.0 KiB
7.0 KiB
adapter
| adapter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Go Adapter
Server Start Command Inference
Priority order for detecting the server start command:
- Existing
harness/config/environment.jsonstartup command, if present cmd/server/main.goexists →go run cmd/server/main.gocmd/api/main.goexists →go run cmd/api/main.gomain.goat root withhttpimport →go run main.go- Fail with actionable error
CLI Binary Inference
cmd/cli/main.goexists →go build -o bin/cli cmd/cli/main.gocmd/<name>/main.goexists →go build -o bin/<name> cmd/<name>/main.gomain.goat root withcobra/flagimport →go build -o bin/app .
Testing Patterns
- Unit tests:
*_test.gofiles alongside source - Integration tests:
//go:build integrationbuild tag →go test -tags=integration ./... - Table-driven tests are idiomatic
Common Frameworks
| Framework | Detection Pattern | Route Style |
|---|---|---|
| chi | github.com/go-chi/chi |
r.Get("/path", handler) |
| gin | github.com/gin-gonic/gin |
r.GET("/path", handler) |
| echo | github.com/labstack/echo |
e.GET("/path", handler) |
| fiber | github.com/gofiber/fiber |
app.Get("/path", handler) |
| gorilla/mux | github.com/gorilla/mux |
r.HandleFunc("/path", handler).Methods("GET") |
| net/http | stdlib | http.HandleFunc("/path", handler) |
Structured Logging
Go projects should use structured loggers. Common patterns to detect:
go.uber.org/zap→zap.String(),zap.Int()log/slog(stdlib) →slog.Info(),slog.With()github.com/rs/zerolog→log.Info().Str().Msg()github.com/sirupsen/logrus→logrus.WithFields()
Unstructured patterns to flag: log.Printf, log.Println, log.Fatalf, fmt.Printf (in non-CLI code)