diff --git a/cookiecutter.json b/cookiecutter.json index ca9d201..fe34224 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -4,6 +4,7 @@ "origin": null, "image": "n", "use_ci": ["gitlab", "circleci", "none"], - "go": "1.11.1", + "go": "1.17.10", + "golangcilint_version": "v1.45.0", "module": "{{ cookiecutter.origin }}" } diff --git a/{{cookiecutter.name}}/.golangci.yml b/{{cookiecutter.name}}/.golangci.yml index b37eff6..8e347b2 100644 --- a/{{cookiecutter.name}}/.golangci.yml +++ b/{{cookiecutter.name}}/.golangci.yml @@ -5,23 +5,31 @@ linters: enable: - megacheck - godox - - interfacer - goconst - whitespace - stylecheck - - golint + - revive - misspell - depguard + disable: + - scopelint + - maligned + - gci presets: - - bugs # bodyclose, errcheck, gosec, govet, rowserrcheck, scopelint, staticcheck, typecheck - - complexity # gocognit, gocyclo, nakedret - - format # gofmt, goimports - - performance # bodyclose, maligned, prealloc, rowserrcheck - - unused # deadcode, ineffassign, structcheck, unparam, unused, varcheck + - bugs # asciicheck, bidichk, bodyclose, contextcheck, durationcheck, errcheck, errchkjson, errorlint, exhaustive, exportloopref, gosec, govet, makezero, nilerr, noctx, rowserrcheck, scopelint, sqlclosecheck, staticcheck, typecheck + - complexity # cyclop, funlen, gocognit, gocyclo, maintidx, nestif + - format # decorder, gci, gofmt, gofumpt, goimports + - performance # bodyclose, maligned, noctx, prealloc + - unused # deadcode, ineffassign, structcheck, unparam, unused, varcheck fast: false # configuration for specific linters linters-settings: + funlen: + lines: 80 + cyclop: + max-complexity: 12 + skip-tests: true nakedret: max-func-lines: 0 # no naked returns goimports: @@ -35,3 +43,10 @@ linters-settings: - github.com/satori/go.uuid packages-with-error-message: - github.com/satori/go.uuid: "Unsafe package, prefer github.com/gofrs/uuid" + +issues: + exclude-rules: + - path: '(.+)_test\.go' + linters: + - funlen + - gocyclo diff --git a/{{cookiecutter.name}}/build/ci/.gitlab-ci.yml b/{{cookiecutter.name}}/build/ci/.gitlab-ci.yml index 756784b..8dfb041 100644 --- a/{{cookiecutter.name}}/build/ci/.gitlab-ci.yml +++ b/{{cookiecutter.name}}/build/ci/.gitlab-ci.yml @@ -36,14 +36,11 @@ test: # Runs code linting lint: stage: test - image: golang:{{cookiecutter.go}}-alpine variables: - GOLANGCILINT_VERSION: v1.21.0 + GOLANGCILINT_VERSION: {{cookiecutter.golangcilint_version}} + image: golangci/golangci-lint:${GOLANGCILINT_VERSION}-alpine script: - - apk update && apk add build-base git - - go mod download - - wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s ${GOLANGCILINT_VERSION} - - ./bin/golangci-lint run + - golangci-lint run -c ../.golangci.yml # Runs dependency vetting # https://github.com/sonatype-nexus-community/nancy diff --git a/{{cookiecutter.name}}/cmd/{{cookiecutter.name}}/main.go b/{{cookiecutter.name}}/cmd/{{cookiecutter.name}}/main.go index 55c27bc..e4a1933 100644 --- a/{{cookiecutter.name}}/cmd/{{cookiecutter.name}}/main.go +++ b/{{cookiecutter.name}}/cmd/{{cookiecutter.name}}/main.go @@ -4,13 +4,12 @@ import ( "io" "os" - "{{cookiecutter.module}}/internal/config" - "{{cookiecutter.module}}/internal/version" - "github.com/rs/zerolog" "github.com/spf13/cobra" - configkit "go.soon.build/kit/config" + + "{{cookiecutter.module}}/internal/config" + "{{cookiecutter.module}}/internal/version" ) // Default logger @@ -23,7 +22,7 @@ var cfg config.Config var defaultLog = config.Log{ Console: false, Verbose: false, - Level: zerolog.LevelDebugValue, + Level: zerolog.DebugLevel.String(), } // Application entry point @@ -60,7 +59,7 @@ func {{cookiecutter.name|replace('-', '')|replace('.', '')}}Cmd() *cobra.Command log = initLogger(cfg.Log) return nil }, - RunE: {{cookiecutter.name|replace('-', '')|replace('.', '')}}Run, + RunE: {{cookiecutter.name|replace('-', '')|replace('.', '')}}Run, } // Global flags pflags := cmd.PersistentFlags() diff --git a/{{cookiecutter.name}}/cmd/{{cookiecutter.name}}/version.go b/{{cookiecutter.name}}/cmd/{{cookiecutter.name}}/version.go index 2a7e53b..2557ae8 100644 --- a/{{cookiecutter.name}}/cmd/{{cookiecutter.name}}/version.go +++ b/{{cookiecutter.name}}/cmd/{{cookiecutter.name}}/version.go @@ -3,9 +3,9 @@ package main import ( "os" - "{{cookiecutter.module}}/internal/version" - "github.com/spf13/cobra" + + "{{cookiecutter.module}}/internal/version" ) // versionCmd returns a CLI command that when run prints diff --git a/{{cookiecutter.name}}/go.mod b/{{cookiecutter.name}}/go.mod index 75142de..e9eb4ca 100644 --- a/{{cookiecutter.name}}/go.mod +++ b/{{cookiecutter.name}}/go.mod @@ -3,5 +3,5 @@ module {{cookiecutter.module}} require ( github.com/rs/zerolog v1.11.0 github.com/spf13/cobra v0.0.3 - go.soon.build/kit/config v0.0.0-20190802105545-9c7d0e7ffbef + go.soon.build/kit/config v0.0.0-20210812141405-28d18278434a ) diff --git a/{{cookiecutter.name}}/go.sum b/{{cookiecutter.name}}/go.sum index be66474..af78af4 100644 --- a/{{cookiecutter.name}}/go.sum +++ b/{{cookiecutter.name}}/go.sum @@ -14,6 +14,7 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -92,16 +93,18 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.soon.build/kit/config v0.0.0-20190802105545-9c7d0e7ffbef h1:pdJta9eCPY1ZUY9jYxNE53T9hpOtyTCCF0b/w2kdoEU= -go.soon.build/kit/config v0.0.0-20190802105545-9c7d0e7ffbef/go.mod h1:kHQq9i7WSbye5tTFzQymPLJqgUDx8DfWE8eO8oL5KEc= +go.soon.build/kit/config v0.0.0-20210812141405-28d18278434a h1:yszeUD9KlZ1xjPp2D9H7Oldq5LUvuw0znFPywBSAG3A= +go.soon.build/kit/config v0.0.0-20210812141405-28d18278434a/go.mod h1:bqF4v1NE/Ycy2OwWXg8J8xQ2zFFWALN13HCiC+UwCHU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= @@ -143,4 +146,6 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=