Skip to main content

Overview

This example shows a minimal envcheck configuration for a Go project. It validates the Go toolchain version and checks for required project files while allowing optional Go environment variables.

Configuration

.envcheck.yaml

What This Checks

Tools

  • go >=1.18.0: Ensures you have Go 1.18+ with generics support and improved module management

Environment Variables

  • GOPATH (optional): Go workspace path - typically not needed with Go modules, but checked if set
  • GOBIN (optional): Installation directory for executables - checked if custom location is configured

Files

  • go.mod: Go module file - required for dependency management in modern Go projects
  • main.go (optional): Entry point for executable - not all Go projects are applications

Expected Output

Tips for Go Projects

With Go modules (introduced in Go 1.11 and default since 1.16), GOPATH is largely optional. The configuration reflects this modern practice.
If you’re upgrading from Go 1.17 to 1.18+, review the release notes for breaking changes, especially around generics and workspace features.
Go 1.18 introduced workspaces (go.work). For multi-module repositories, consider adding go.work as an optional file check.

Common Variations

Web API Service

Add service-specific requirements:

Microservices Architecture

Validate service dependencies:

CLI Tool Development

Check CLI-specific tooling:

Library/Package Development

Minimal checks for libraries:

Workspace Setup (Go 1.18+)

Multi-module workspace validation:

gRPC Service

Validate Protocol Buffers toolchain:

Go-Specific Considerations

Go Version Management

Use one of these tools to manage Go versions:
  • gvm: Go Version Manager
  • asdf: Multi-runtime version manager with Go plugin
  • goenv: Simple Go version management

Module Initialization

If go.mod is missing, initialize it:

Private Modules

For private repositories, configure GOPRIVATE:

Build Tags

For projects using build tags, document required environment:

Learn More