Skip to content

Commit

Permalink
Merge pull request #2 from lawzava/feat/ugprade
Browse files Browse the repository at this point in the history
✨ upgrade & cleanup
  • Loading branch information
lawzava authored Oct 9, 2023
2 parents 4fab71b + f1453dd commit 0dbe18a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.41.1
version: v1.54.2
80 changes: 3 additions & 77 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
enable-all: true
disable:
- depguard
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
7 changes: 4 additions & 3 deletions states.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
}
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 0dbe18a

Please sign in to comment.