diff --git a/.github/workflows/golang.yml b/.github/workflows/golang.yml index eea3175..71c7911 100644 --- a/.github/workflows/golang.yml +++ b/.github/workflows/golang.yml @@ -9,7 +9,7 @@ jobs: - name: Setup Go for use with actions uses: actions/setup-go@v2 with: - go-version: 1.15 + go-version: 1.21 - uses: actions/checkout@v2 - uses: actions/cache@v2 with: diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml index ebfbe9a..717c287 100644 --- a/.github/workflows/golangci.yml +++ b/.github/workflows/golangci.yml @@ -10,4 +10,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.41.1 + version: v1.54.2 diff --git a/.golangci.yml b/.golangci.yml index 27ad51a..5f97dfc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,80 +18,6 @@ linters-settings: extra-rules: true linters: - disable-all: true - enable: - - bodyclose - - deadcode - - depguard - - dogsled - - dupl - - errcheck - - gochecknoglobals - - gochecknoinits - - gocognit - - goconst - - gocritic - - gocyclo - - godot - - gofmt - - goimports - - gomnd - - gomodguard - - goprintffuncname - - gosec - - gosimple - - govet - - ineffassign - - lll - - misspell - - nakedret - - nestif - - prealloc - - rowserrcheck - - staticcheck - - structcheck - - stylecheck - - typecheck - - unconvert - - unparam - - unused - - varcheck - - whitespace - - wsl - - asciicheck - - godox - - nolintlint - - goerr113 - - exhaustive - - exportloopref - - gofumpt - - goheader - - noctx - - sqlclosecheck - - nlreturn - - errorlint - - exhaustivestruct - - paralleltest - - tparallel - - wrapcheck - - forbidigo - - makezero - - predeclared - - thelper - - cyclop - - durationcheck - - forcetypeassert - - gci - - gomoddirectives - - importas - - nilerr - - promlinter - - revive - - tagliatelle - - testpackage - - wastedassign - - ifshort - # - interfacer # Deprecated - # - golint # Deprecated - # - maligned # Deprecated - # - scopelint # Deprecated \ No newline at end of file + enable-all: true + disable: + - depguard \ No newline at end of file diff --git a/README.md b/README.md index 6991f0c..bdbcfde 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ![GolangCI](https://github.com/lawzava/go-postal/workflows/golangci/badge.svg?branch=main) -[![Version](https://img.shields.io/badge/version-v1.1.1-green.svg)](https://github.com/lawzava/go-postal/releases) +[![Version](https://img.shields.io/badge/version-v1.2.0-green.svg)](https://github.com/lawzava/go-postal/releases) [![Go Report Card](https://goreportcard.com/badge/github.com/lawzava/go-postal)](https://goreportcard.com/report/github.com/lawzava/go-postal) [![Coverage Status](https://coveralls.io/repos/github/lawzava/go-postal/badge.svg?branch=main)](https://coveralls.io/github/lawzava/go-postal?branch=main) [![Go Reference](https://pkg.go.dev/badge/github.com/lawzava/go-postal.svg)](https://pkg.go.dev/github.com/lawzava/go-postal) diff --git a/go.mod b/go.mod index 9a8b393..8e83b1b 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,13 @@ module github.com/lawzava/go-postal -go 1.15 +go 1.21 + +require github.com/stretchr/testify v1.7.0 require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect - github.com/stretchr/testify v1.7.0 + github.com/pmezard/go-difflib v1.0.0 // indirect gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/states.go b/states.go index 9d28bf5..6b7a065 100644 --- a/states.go +++ b/states.go @@ -184,7 +184,8 @@ func (s State) Is(state State) bool { } // Name returns full state name from state code. -// nolint:gocyclo,cyclop // allow higher complexity +// +//nolint:gocyclo,cyclop,funlen // allow higher complexity func (s State) Name() StateName { switch s { case Alaska: @@ -302,7 +303,7 @@ func FindState(postal string) (State, error) { return "", fmt.Errorf("invalid code '%s': %w", postal, ErrInvalidCode) } - code, err := strconv.ParseInt(postal, 10, 64) // nolint:gomnd // allow fixed integer size + code, err := strconv.ParseInt(postal, 10, 64) if err != nil { return "", fmt.Errorf("code is not a valid number: %w", ErrInvalidCode) } @@ -319,7 +320,7 @@ func FindState(postal string) (State, error) { return state, nil } -// nolint:gocyclo,gomnd,cyclop // allow higher complexity & zip codes as integers +//nolint:gocyclo,gomnd,cyclop,funlen // allow higher complexity & zip codes as integers func getStateFromCode(code int64) State { switch { case rng(code, 99500, 99999): diff --git a/validate.go b/validate.go index f77146b..d2832f7 100644 --- a/validate.go +++ b/validate.go @@ -6,5 +6,5 @@ const codeChecker = "^\\d{5}(?:[-\\s]\\d{4})?$" // IsValid checks whether the supplied request is valid postal code. func IsValid(code string) bool { - return regexp.MustCompile(codeChecker).Match([]byte(code)) + return regexp.MustCompile(codeChecker).MatchString(code) }