Go CLI for managing GoClaw AI agent gateway servers.
- Language: Go 1.25
- CLI: Cobra (commands) + Viper-style config
- Transport: HTTP REST + WebSocket RPC (gorilla/websocket)
- Config:
~/.goclaw/config.yaml+ env vars + flags
go build ./... # Compile check
go vet ./... # Static analysis
go test ./... # Run all tests
go test -count=1 ./... # Skip test cache
make build # Build binary with ldflags
make install # Install to GOPATH/bincmd/ # Cobra command files (1 per resource group)
internal/
├── client/ # HTTP + WebSocket + auth clients
├── config/ # Config loader (~/.goclaw/)
├── output/ # Table/JSON/YAML formatters
└── tui/ # Interactive prompts
- Go snake_case file naming
- Cobra command pattern: register in
init(), implement asRunE - Config precedence: flags > env vars > config file
- Token stored in credential store (not config.yaml)
- All destructive ops require
--yesor interactive confirmation - Dual mode: interactive (table output) + automation (JSON/YAML)
newHTTP()/newWS()— create authenticated clients from global configbuildBody()— construct request body from flag values, skip emptyreadContent()— read from@filepathor literal stringunmarshalMap()/unmarshalList()— parse JSON responsesprinter.Print()— output in configured format
- Unit tests in
*_test.goalongside source - Use
httptest.NewServerfor HTTP client tests - Use gorilla/websocket upgrader for WS tests
- No CGO race detector on Windows (use Linux CI)