custom-gcl
is a custom version of golangci-lint
that includes custom linters.
- Change versions in this repo code (Dockerfile, go.mod)
- Create PR and merge changes to master
- AWS Codebuild will automatically detect changes, build new image and upload to
271332529381.dkr.ecr.eu-west-1.amazonaws.com/golang-with-dependencies:latest
- Monorepo services will automatically catch new version during its next build
- Create a Go file with the linter logic. For example,
analyzer.go
:
package custom-code-analysis-tools
import (
"golang.org/x/tools/go/analysis"
)
var ExampleAnalyzer = &analysis.Analyzer{
Name: "example",
Doc: "this is an example analyzer",
Run: run,
}
func run(pass *analysis.Pass) (interface{}, error) {
for _, file := range pass.Files {
// Implement your analysis logic here
pass.Reportf(file.Pos(), "example warning")
}
return nil, nil
}
func New(conf any) ([]*analysis.Analyzer, error) {
return []*analysis.Analyzer{ExampleAnalyzer}, nil
}
- Ensure your project utilizes a go.mod file for managing dependencies.
- Define your building configuration into
.custom-gcl.yml
.
version: v1.57.0
plugins:
# a plugin from a Go proxy
- module: 'github.com/golangci/plugin1'
import: 'github.com/golangci/plugin1/foo'
version: v1.0.0
# a plugin from local source
- module: 'github.com/golangci/plugin2'
path: /my/local/path/plugin2
- From the root directory of your plugin project, run the command
golangci-lint custom
(orgolangci-lint custom -v
to have logs):
golangci-lint custom -v
To configure golangci-lint
to use your custom linters, perform the following steps:
- Add or update the
.golangci.yml
file in the root directory of the project you want to lint:
linters-settings:
custom:
your_linter_name:
type: "module"
description: This is an example usage of a plugin linter.
settings:
message: hello
linters:
disable-all: true
enable:
- your_linter_name