Skip to main content

Code Style Guide

Station follows standard Go conventions with some project-specific guidelines.

Go Style

Official Guidelines

Station follows the official Go style guides:

Formatting

Linting

The project uses golangci-lint with these enabled linters:
  • gofmt - Format checking
  • goimports - Import organization
  • govet - Go vet checks
  • errcheck - Error handling
  • staticcheck - Static analysis
  • gosimple - Simplifications
  • ineffassign - Unused assignments

Naming Conventions

Packages

Functions and Methods

Interfaces

Variables

Constants

Code Organization

File Structure

Import Grouping

Error Handling

Error Wrapping

Custom Errors

Don’t Ignore Errors

Context Usage

Concurrency

Channel Patterns

Mutex Usage

Documentation

Package Comments

Function Comments

Inline Comments

Testing Style

See the Testing Guide for detailed testing conventions.

Pre-commit Checklist

Before committing:
  1. Format code: make fmt
  2. Run linter: make lint
  3. Run tests: make test
  4. Check for issues: make check (runs fmt, lint, test)

Next Steps

Development Setup

Set up your development environment

Testing

Writing and running tests