Raised: $0
0% of monthly goal Help us cross the finish line!
Goal: $12,000
Raised: $0 Goal: $12,000
0% of monthly goal Help us cross the finish line!
Sponsor DDEV

If you find this add-on useful, please star it on GitHub — stars show appreciation and help maintainers know their work matters.

add-on registry tests last commit release

DDEV Pi Golang

📚 Related Documentation: SUMMARY.md - Tool selection philosophy TOOLS.md - Detailed tool reference

Overview

This add-on extends the ddev-pi addon with comprehensive Golang development capabilities, transforming the Pi coding agent into an expert Go developer.

Features

Go Runtime

Essential Go Tools (10 tools)

Language Server:

Code Formatting:

Linting & Analysis:

Testing:

Development Tools:

Pi Agent Enhancements

The 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.

Installation

ddev add-on get mxr576/ddev-pi-golang
ddev restart

After installation, commit the .ddev directory to version control.

Usage

Starting the Pi Service

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.

Basic Go Development

# 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 ./...

Using the Pi Agent for Go Development

# 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"

Advanced Customization

Changing Go Version

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

Changing golangci-lint Version

echo "GOLANGCI_LINT_VERSION=1.61.0" >> .ddev/.env.pi
ddev restart && ddev start --profiles=pi

Customization Options

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.

Go Best Practices Enforced by Pi Agent

The Pi agent extension automatically guides you to follow these practices:

Troubleshooting

Module cache issues

Clear the Go module cache:

ddev exec -s pi go clean -modcache

Available Go Commands Reference

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

Credits

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.