Skip to content

Commit

Permalink
Lint fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gglachant committed Oct 18, 2022
1 parent 6f6722c commit 7604e0f
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 95 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
Expand All @@ -32,8 +35,9 @@ jobs:
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true
# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true
Expand Down
176 changes: 95 additions & 81 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,97 +3,111 @@ max-same-issues: 0
linters-settings:
gofumpt:
extra-rules: true
goimports:
local-prefixes: gitlab.nereides.weborama.com
govet:
check-shadowing: true
enable-all: true
issues:
exclude:
- "directive `.+` should be written without leading space as `.+`"
exclude-rules:
- path: _test.go
linters:
- gocognit
- funlen
- lll
- gomnd
- maintidx
- path: _test.go
text: "fieldalignment: struct ((with .+ pointer bytes)|(of size .+)) could be .+"
linters:
enable:
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- cyclop
- deadcode
- decorder
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- gofmt
- gofumpt
- goheader
- goimports
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- ifshort
- importas
- ineffassign
- ireturn
- lll
- maintidx
- makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- paralleltest
- prealloc
- predeclared
- promlinter
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- tagliatelle
- tenv
- testpackage
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- varcheck
- varnamelen
- wastedassign
- whitespace
- wrapcheck
- wsl
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- cyclop
- decorder
- depguard
- dogsled
- dupl
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exhaustruct
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- gofmt
- gofumpt
- goheader
- goimports
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- importas
- ineffassign
- interfacebloat
- ireturn
- lll
- loggercheck
- maintidx
- makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- reassign
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
- tagliatelle
- tenv
- testableexamples
- testpackage
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- varnamelen
- wastedassign
- whitespace
- wrapcheck
- wsl
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/weborama/uint128

go 1.12
go 1.19
10 changes: 6 additions & 4 deletions operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ package uint128 // import "github.com/weborama/uint128"
import "math/bits"

// Cmp compares two Uint128 and returns one of the following values:
// -1 if x < y
// 0 if x == y
// +1 if x > y
//
// -1 if x < y
// 0 if x == y
// +1 if x > y
//
// nolint: varnamelen
func Cmp(x, y Uint128) int {
if x.H < y.H {
Expand Down Expand Up @@ -128,7 +130,7 @@ func Add128(x, y, carry Uint128) (sum, carryOut Uint128) {

// Incr increments x by one.
func Incr(x Uint128) Uint128 {
return Add(x, Uint128{L: 1})
return Add(x, Uint128{H: 0, L: 1})
}

// Sub subtracts x and y.
Expand Down
11 changes: 6 additions & 5 deletions uint128.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Uint128 struct {

// Zero is a 0 valued Uint128.
func Zero() Uint128 {
return Uint128{}
return Uint128{H: 0, L: 0}
}

// MaxUint128 returns the maximum value of an Uint128.
Expand All @@ -33,9 +33,10 @@ func MaxUint128() Uint128 {
}

// Cmp compares two Uint128 and returns one of the following values:
// -1 if x < y
// 0 if x == y
// +1 if x > y
//
// -1 if x < y
// 0 if x == y
// +1 if x > y
func (x Uint128) Cmp(y Uint128) int {
return Cmp(x, y)
}
Expand Down Expand Up @@ -115,7 +116,7 @@ func NewFromString(str string) (x Uint128, err error) {
x = Uint128{0, 0}
// nolint: gomnd // Number of characters in a hexadecimal representation of an uint128
if len(str) > 32 {
return x, fmt.Errorf("s:%s length greater than 32", str)
return x, fmt.Errorf("s:%s length greater than 32", str) // nolint: goerr113
}

b, err := hex.DecodeString(fmt.Sprintf("%032s", str))
Expand Down

0 comments on commit 7604e0f

Please sign in to comment.