Middle+
What development practices does your team follow?
sobes.tech AI
Answer from AI
Our Go development team practices the following approaches:
- Code Review — a mandatory step before merging code, helps maintain quality and share knowledge.
- Using interfaces for abstraction and easier testing.
- Unit testing with coverage of key functions.
- CI/CD for automated build and deployment.
- Strict coding style using
gofmtandgolint. - Context (context.Context) for managing execution time and cancellation of operations.
Example of using interface and context:
package main
import (
"context"
"fmt"
"time"
)
type Service interface {
Process(ctx context.Context) error
}
type MyService struct{}
func (s *MyService) Process(ctx context.Context) error {
select {
case <-time.After(2 * time.Second):
fmt.Println("Process finished")
return nil
case <-ctx.Done():
return ctx.Err()
}
}
func main() {
svc := &MyService{}
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := svc.Process(ctx)
if err != nil {
fmt.Println("Process error:", err)
}
}
This approach ensures flexibility, testability, and reliability of the code.