Skip to content

Commit

Permalink
WIP proof of concept of custom golangci-lint plugings
Browse files Browse the repository at this point in the history
current solution requires golangci-lint install per go get because cgo needs to be enabled for plugings
golangci/golangci-lint#1276
  • Loading branch information
mwieser committed May 31, 2022
1 parent 6eddec0 commit ee5e0f4
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 43 deletions.
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ linters:
# https://github.com/polyfloyd/go-errorlint
# ensure we are comparing errors via errors.Is, types/values via errors.As and wrap errors with %w.
- errorlint

# custom linter for secrets in our server config
- secrets
linters-settings:
custom:
secrets:
path: /app/lint/secrets/bin/secrets.so
description: Checks that no secret is hardcoded in code
original-url: allaboutapps.dev/aw/secrets-linter

17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ build: ##- Default 'make' target: sql, swagger, go-generate, go-format, go-build
@$(MAKE) build-pre
@$(MAKE) go-format
@$(MAKE) go-build
@$(MAKE) build-linters
@$(MAKE) lint

# useful to ensure that everything gets resetuped from scratch
Expand Down Expand Up @@ -353,6 +354,22 @@ git-merge-go-starter: ##- Merges upstream GIT_GO_STARTER_TARGET into current HEA
git merge --no-commit --no-ff --allow-unrelated-histories ${GIT_GO_STARTER_TARGET} || true
@echo "Done. We recommend to run 'make force-module-name' to automatically fix all import paths."

### -----------------------
# --- Linters
### -----------------------
build-linters:
@$(MAKE) build-secrets-linter

build-secrets-linter:
@echo "make build-secrets-linter"
@cd lint/secrets && go build \
-o bin/ \
-mod=mod \
-modfile=go.mod \
-buildmode=plugin \
secrets.go


### -----------------------
# --- Helpers
### -----------------------
Expand Down
22 changes: 12 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ require (
github.com/rs/zerolog v1.26.1
github.com/rubenv/sql-migrate v1.1.1
github.com/spf13/cobra v1.4.0
github.com/spf13/viper v1.10.1
github.com/spf13/viper v1.11.0
github.com/stretchr/testify v1.7.1
github.com/subosito/gotenv v1.2.0
github.com/volatiletech/null/v8 v8.1.2
github.com/volatiletech/randomize v0.0.1
github.com/volatiletech/sqlboiler/v4 v4.9.2
github.com/volatiletech/strmangle v0.0.2
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150
golang.org/x/text v0.3.7
google.golang.org/api v0.74.0
)
Expand All @@ -53,7 +53,7 @@ require (
github.com/denisenkom/go-mssqldb v0.12.0 // indirect
github.com/ericlagergren/decimal v0.0.0-20211103172832-aca2edc11f73 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-gorp/gorp/v3 v3.0.2 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-openapi/analysis v0.21.2 // indirect
Expand All @@ -72,14 +72,15 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gax-go/v2 v2.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.3.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/labstack/gommon v0.3.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand All @@ -90,11 +91,12 @@ require (
github.com/mattn/go-sqlite3 v1.14.12 // indirect
github.com/mitchellh/cli v1.1.2 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
Expand All @@ -108,12 +110,12 @@ require (
github.com/volatiletech/inflect v0.0.1 // indirect
go.mongodb.org/mongo-driver v1.8.4 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b // indirect
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de // indirect
google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac // indirect
google.golang.org/grpc v1.45.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
Expand Down
Loading

0 comments on commit ee5e0f4

Please sign in to comment.