Isaev Denis edited this page Nov 29, 2018 · 12 revisions


An analysis run in can be configured by .golangci.(yml|toml|json) file. We will use the yaml format for examples.

A config file controls:

  1. how golangci-lint is run: which linters are enabled, which issues to skip, etc.
  2. service work: how to fetch dependencies and prepare the environment, which version of golangci-lint to use, etc.

golangci-lint configuration

The description of this part of configuration can be found in golangci-lint doc

Service configuration

The service section isn't required in .golangci.yml config file, use it only if can't analyze your repo by default.

.golangci.yml example:

  project-path: # vanity import path if needed
  golangci-lint-version: 1.12.x
    - make deps
    - make generate

How to test

To check the configuration, to check how works with your repo, run:

docker run --rm -v $(pwd):/goapp -e RUN=1 -e golangci/build-runner goenvbuild

Use your repo's path instead of If this run timeouts add -e TIMEOUT=10m to the docker command.

Config directives

  1. project-path - by default the project source code will be placed in $GOPATH/src/ By if vanity imports are necessary you may specify the import path by this directive. For example, the project may specify project-path:

    Also, even if this option isn't specified we try to auto-detect a vanity import path:

    • parse go.mod file
    • search import aliases
    • extract go_import_path from .travis.yml
    • extract package from glide.yaml

    Setting this directive often can be useful when you connect forked repos to GolangCI to properly set the project path to the parent repository.

  2. golangci-lint-version: set golangci-lint version to use. The default value is 1.12.x - it means that we use the latest patch version in 1.12. You can set values like 1.12.1, 1.11.x. It's recommended to set the value to the version you use in CI and locally: otherwise there can be a mismatch between versions: e.g. you can see new issues in

  3. prepare: the list of shell commands to execute for the project preparation: dependencies fetching, running code generation, etc. Without this directive we try to fetch dependencies:

  • if the repo has non-empty vendor dir we do nothing
  • otherwise we guess the dependency tool: dep, godep, govendor, go mod or glide
  • if we can't fetch dependencies we fallback to go get. We run commands by bash -c {command} inside golangci/build-runner docker container.


Install needed library for Ullaakut/cameradar analysis (link):


    - apt-get update && apt-get install -y libcurl4-gnutls-dev
    - dep ensure

Run code generation before analysis (link):


    - make deps generate

Install libsecret-1 before analysis (link):


    - apt-get update && apt-get install -y libsecret-1-dev
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.