If you find this add-on useful, please star it on GitHub — stars show appreciation and help maintainers know their work matters.
| 📚 Related Documentation: SUMMARY.md - Tool selection philosophy | TOOLS.md - Detailed tool reference |
This add-on extends the ddev-pi addon with comprehensive Golang development capabilities, transforming the Pi coding agent into an expert Go developer.
Language Server:
gopls - Official Go language server for IDE featuresCode Formatting:
goimports - Format code and manage imports automaticallyLinting & Analysis:
golangci-lint - Comprehensive linting (50+ linters in one)staticcheck - Advanced static analysis for deeper insightsgovulncheck - Security vulnerability scanning for dependenciesTesting:
gotests - Generate table-driven test boilerplatemockgen - Generate mock implementations for testingDevelopment Tools:
dlv (Delve) - Full-featured debuggerimpl - Generate interface method stubsThe addon includes a custom Pi extension that:
Extension Location:
pi/global/agent/extensions/golang-development.ts
Advanced users can customize the extension by editing this file.
ddev add-on get mxr576/ddev-pi-golang
ddev restart
After installation, commit the .ddev directory to version control.
The Pi service uses a Docker Compose profile and must be started explicitly.
For existing projects:
ddev start --profiles=pi
After addon installation or configuration changes:
ddev restart && ddev start --profiles=pi
Note: The ddev restart ensures the addon configuration is loaded before starting the Pi service.
# Enter the Pi container
ddev ssh -s pi
# Create a new Go project
mkdir myproject && cd myproject
go mod init github.com/username/myproject
# Create main.go
cat > main.go << 'EOF'
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
EOF
# Run your program
go run .
# Format code and organize imports
goimports -w .
# Run linters
golangci-lint run
# Run tests with race detection
go test -race ./...
# Check for vulnerabilities
govulncheck ./...
# Start an interactive Pi session
ddev pi
# Example prompts:
# "Create a new Go web service using the standard library"
# "Add unit tests for this function"
# "Refactor this code to follow Go best practices"
# "Add proper error handling to this function"
To use a different Go version, set the environment variable before installation:
echo "GOLANG_VERSION=1.22.5" >> .ddev/.env.pi
ddev restart && ddev start --profiles=pi
echo "GOLANGCI_LINT_VERSION=1.61.0" >> .ddev/.env.pi
ddev restart && ddev start --profiles=pi
| Variable | Default | Description |
|---|---|---|
GOLANG_VERSION |
1.26.4 |
Go version to install (check latest: https://go.dev/VERSION?m=text) |
GOLANGCI_LINT_VERSION |
1.62.2 |
golangci-lint version |
Note: Changing versions requires rebuilding the Pi container. Due to ddev/ddev#8463, use the command above rather than ddev utility rebuild.
The Pi agent extension automatically guides you to follow these practices:
Clear the Go module cache:
ddev exec -s pi go clean -modcache
| Command | Description |
|---|---|
go run . |
Run the main package |
go build |
Compile packages and dependencies |
go test ./... |
Run all tests recursively |
go test -v ./... |
Run tests with verbose output |
go test -race ./... |
Run tests with race detection |
go test -cover ./... |
Run tests with coverage |
go mod init <module> |
Initialize a new module |
go mod tidy |
Add missing and remove unused modules |
go get <package>@<version> |
Add or update a dependency |
go install <package>@latest |
Install a Go binary |
go vet ./... |
Report likely mistakes |
goimports -w . |
Format code and fix imports |
golangci-lint run |
Run comprehensive linting |
staticcheck ./... |
Advanced static analysis |
govulncheck ./... |
Check for vulnerabilities |
gotests -all -w file.go |
Generate tests for file |
dlv debug |
Start debugger |
impl 'r *Type' io.Reader |
Generate interface stubs |
mockgen -source=file.go |
Generate mocks |
Contributed and maintained by @mxr576
If you find this add-on useful, please star it on GitHub — stars show appreciation and help maintainers know their work matters.