Skip to content

GolangCI-Lint

This guide explains how to run GolangCI-Lint with CloudAEye.

Overview

GolangCI-Lint is a fast, powerful, and flexible linter runner for Go. It runs many popular Go linters in parallel, reuses build and analysis caches, and supports a wide range of configuration options.

Key Features

  • Over 100 built-in linters: from style and complexity checks to security and performance analysis.
  • YAML configuration support: .golangci.yml, .golangci.toml, .golangci.json, etc
  • Parallel execution + caching: runs linters concurrently and caches results for speed.
  • Flexible output options: support for text, JSON, HTML, and CI formats.
  • Configurable issue rules: set severity, limit issues per linter, and filter by path.
  • Run settings control: adjust timeout, concurrency, build tags, and more.

Prerequisites

Step 1: Register

Sign up with CloudAEye SaaS.

Step 2: Install GitHub App

Integrate with GitHub by installing the GitHub app.

Step 3: Connect Github Repositorie

Connect the repositories where you would like to use CloudAEye Code Review features.

Step 4: Configure the Linter

Configure the desired linter.

Configuration

CloudAEye provides a best practices configuration for GolangCI-Lint favors enabling a core set of essential linters.

If your repository already has GolangCI-Lint configured, CloudAEye will automatically use that setup. You may also enter your desired configuration.

Use repo config

CloudAEye automatically reads your repository’s existing GolangCI-Lint configuration and uses it as is. No additional setup is needed.

Common GolangCI-Lint Configuration File Locations & Formats

You can use any of the following filenames:

  • .golangci.yml
  • .golangci.yaml
  • .golangci.toml
  • .golangci.json

These files live at the root of your project and contain settings such as enabled linters, thresholds, exclusions, and custom rules.

A typical Go project uses .golangci.yml, but all supported formats behave the same way.

Manual

You may enter the GolangCI-Lint configuration you would like to use.

Core (balanced)

For new Go projects, the recommended core linters to enable in golangci-lint focus
on catching bugs, improving code quality, and enforcing style consistency. A
sensible starting set includes:

  • govet: essential for catching suspicious constructs and bugs.
  • ineffassign: detects inefficiencies in assignments.
  • unused: finds unused variables, constants, functions.
  • staticcheck: a comprehensive suite for bugs and style.
  • errcheck: ensures errors are checked.
  • gocyclo (cyclop): measures function complexity.
  • goconst: finds repeated constants.
  • gocritic: offers a variety of style and correctness checks.
  • gosec: security-related checks.
  • contextcheck: verifies correct use of context in tests.
  • copyloopvar: catches loop variable misuse (Go 1.22+).
  • errorlint: improves error handling practices.
  • sqlclosecheck, rowserrcheck, bodyclose: resource management checks.

This set balances core bug detection, style conformity, and security for maintainable, robust code in new projects.


Install: brew install golangci-lint OR: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# .golangci.yml
run:
  timeout: 5m
  tests: true
  skip-dirs:
    - vendor
    - generated
    - mocks
issues:
  exclude-use-default: false
  exclude:
    - "error return value not checked.*(Close|Write|Flush|Print).*"
    - "SA9003:"   # empty branch
  max-issues-per-linter: 50
  max-same-issues: 3
  require-explanation: true
  require-specific: true
linters:
  enable:
    - govet
    - errcheck
    - staticcheck
    - gosimple
    - ineffassign
    - unused
    - gocyclo
    - goconst
    - gocritic
    - gosec
    - errorlint
    - exportloopref
    - misspell
  disable:
    - funlen    # enable later as codebase allows
linters-settings:
  gocyclo:
    min-complexity: 15

GolangCI-Lint

Extended (strict)


Install: brew install golangci-lint OR: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# .golangci.yml
run:
  timeout: 5m
  tests: true
  skip-dirs:
    - vendor
    - generated
    - mocks
  modules-download-mode: readonly
issues:
  max-issues-per-linter: 50
  max-same-issues: 3
  exclude-use-default: false
  exclude:
    - "error return value not checked.*(Close|Write|Flush|Print).*"
    - "SA9003:"
linters:
  enable:
    - errcheck
    - gosimple
    - govet
    - ineffassign
    - staticcheck
    - unused
    - typecheck
    - gofmt
    - goimports
    - revive
    - gosec
    - unparam
    - prealloc
    - gocyclo
    - nestif
    - gocognit
    - misspell
    - dupl
    - exportloopref
    - tparallel
    - testpackage
  disable:
    - maligned
    - scopelint
    - interfacer
    - exhaustivestruct
linters-settings:
  revive:
    ignore-generated-header: true
    severity: warning
    confidence: 0.8
    rules:
      - name: indent-error-flow
      - name: var-naming
      - name: unexported-return
      - name: exported
        arguments: ["checkPrivateReceivers"]
  gofmt:
    simplify: true
  goimports:
    local-prefixes: github.com/yourorg/yourproject
  gocyclo:
    min-complexity: 15
  gocognit:
    min-complexity: 20
  dupl:
    threshold: 100
  errcheck:
    check-type-assertions: true
  gosec:
    excludes:
      - G104
output:
  sort-results: true
  print-issued-lines: true
  print-linter-name: true

File Extensions

GolangCI-Lint will run on files that use any of the following extensions:

.go, go.mod

References