Loading...
Loading...
This skill should be used when writing, refactoring, or testing Go code. It provides idiomatic Go development patterns, TDD-based workflows, project structure conventions, and testing best practices using testify/require and mockery. Activate this skill when creating new Go features, services, packages, tests, or when setting up new Go projects.
npx skill4agent add jumppad-labs/jumppad go-dev-guidelines*_test.gomocks//cmd/internal/pkggo mod initgithub.com/stretchr/testify/requiremocks/anyinterface{}anyinterface{}project-root/
├── cmd/ # Main applications
│ └── myapp/
│ └── main.go
├── internal/ # Private application code
│ ├── handler/ # HTTP handlers
│ │ ├── handler.go
│ │ ├── handler_test.go
│ │ └── mocks/ # Mocks for handler interfaces
│ ├── service/ # Business logic
│ │ ├── service.go
│ │ ├── service_test.go
│ │ └── mocks/
│ └── repository/ # Data access
│ ├── repository.go
│ ├── repository_test.go
│ └── mocks/
├── pkg/ # Public library code
│ └── client/
│ ├── client.go
│ ├── client_test.go
│ └── mocks/
├── api/ # API definitions (OpenAPI, protobuf)
├── configs/ # Configuration files
├── go.mod
├── go.sum
└── README.md// Unit test with mock
func TestServiceCreate(t *testing.T) {
mockRepo := mocks.NewRepository(t)
mockRepo.On("Save", mock.Anything).Return(nil)
svc := NewService(mockRepo)
err := svc.Create(context.Background(), data)
require.NoError(t, err)
mockRepo.AssertExpectations(t)
}
// Separate negative test
func TestServiceCreate_RepoError(t *testing.T) {
mockRepo := mocks.NewRepository(t)
mockRepo.On("Save", mock.Anything).Return(errors.New("db error"))
svc := NewService(mockRepo)
err := svc.Create(context.Background(), data)
require.Error(t, err)
require.Contains(t, err.Error(), "db error")
}handlerserviceuser_service.gouser_service_test.goUserServiceHTTPHandler-erReaderWriterUserRepository| If You Need To... | See This Resource |
|---|---|
| Set up a new Go project structure | Project Structure |
| Understand Go naming conventions | Naming Conventions |
| Write tests with TDD, testify/require, and mockery | Testing Guide |
| Organize packages, interfaces, and dependencies | Code Organization |
| Handle errors idiomatically | Error Handling |
| Work with goroutines, channels, and context | Concurrency Patterns |
| Manage dependencies and go.mod | Dependencies |
| See complete working examples | Complete Examples |
references/