File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- on : [pull_request]
1+ on : [ pull_request ]
22name : Test
33jobs :
4+ lint :
5+ runs-on : ubuntu-latest
6+ steps :
7+ - name : Install Go
8+ uses : actions/setup-go@v2
9+ with :
10+ go-version : 1.15.x
11+ - name : Checkout code
12+ uses : actions/checkout@v2
13+ - name : vet
14+ run : make vet
15+ - name : fmt
16+ run : make fmt-check
17+ - name : revive
18+ run : make revive
19+ golangci :
20+ runs-on : ubuntu-latest
21+ steps :
22+ - name : Checkout code
23+ uses : actions/checkout@v2
24+ - name : golangci-lint
25+ uses : golangci/golangci-lint-action@v2
26+ with :
27+ version : v1.31
28+
429 test :
530 strategy :
631 matrix :
7- go-version : [1.10.x, 1.15.x]
8- os : [ubuntu-latest, macos-latest, windows-latest]
32+ go-version : [ 1.10.x, 1.15.x ]
33+ os : [ ubuntu-latest, macos-latest, windows-latest ]
934 runs-on : ${{ matrix.os }}
1035 steps :
11- - name : Install Go
12- uses : actions/setup-go@v2
13- with :
14- go-version : ${{ matrix.go-version }}
15- - name : Checkout code
16- uses : actions/checkout@v2
17- - name : Test
18- run : go test ./...
36+ - name : Install Go
37+ uses : actions/setup-go@v2
38+ with :
39+ go-version : ${{ matrix.go-version }}
40+ - name : Checkout code
41+ uses : actions/checkout@v2
42+ - name : Test
43+ run : make test
Original file line number Diff line number Diff line change 1+ coverage.out
2+ .idea /
Original file line number Diff line number Diff line change 1+ linters :
2+ enable :
3+ - gosimple
4+ - deadcode
5+ - typecheck
6+ - govet
7+ - errcheck
8+ - staticcheck
9+ - unused
10+ - structcheck
11+ - varcheck
12+ - golint
13+ - dupl
14+ # - gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
15+ - gofmt
16+ - misspell
17+ - gocritic
18+ enable-all : false
19+ disable-all : true
20+ fast : false
21+
22+ run :
23+ timeout : 3m
24+
25+ linters-settings :
26+ gocritic :
27+ disabled-checks :
28+ - ifElseChain
29+
30+ issues :
31+ exclude-rules :
32+ # Exclude some linters from running on tests files.
33+ - path : _test\.go
34+ linters :
35+ - gocyclo
36+ - errcheck
37+ - dupl
38+ - gosec
39+ - unparam
40+ - staticcheck
Original file line number Diff line number Diff line change 1+ ignoreGeneratedHeader = false
2+ severity = " warning"
3+ confidence = 0.8
4+ errorCode = 0
5+ warningCode = 0
6+
7+ [rule .blank-imports ]
8+ [rule .context-as-argument ]
9+ [rule .context-keys-type ]
10+ [rule .dot-imports ]
11+ [rule .error-return ]
12+ [rule .error-strings ]
13+ [rule .error-naming ]
14+ [rule .exported ]
15+ [rule .if-return ]
16+ [rule .increment-decrement ]
17+ [rule .var-naming ]
18+ [rule .var-declaration ]
19+ [rule .package-comments ]
20+ [rule .range ]
21+ [rule .receiver-naming ]
22+ [rule .time-naming ]
23+ [rule .unexported-return ]
24+ [rule .indent-error-flow ]
25+ [rule .errorf ]
Original file line number Diff line number Diff line change 1+ GO_PACKAGE := github.com/6543/go-version
2+
3+ GO ?= go
4+ GOFMT ?= gofmt -s
5+ SHASUM ?= shasum -a 256
6+
7+ GO_SOURCES := $(shell find . -type f -name "* .go")
8+
9+ .PHONY : all
10+ all : clean test
11+
12+ .PHONY : clean
13+ clean :
14+ $(GO ) clean -i ./...
15+
16+ .PHONY : fmt
17+ fmt :
18+ $(GOFMT ) -w $(GO_SOURCES )
19+
20+ .PHONY : fmt-check
21+ fmt-check :
22+ # get all go files and run go fmt on them
23+ @diff=$$($(GOFMT ) -d $(GO_SOURCES ) ) ; \
24+ if [ -n " $$ diff" ]; then \
25+ echo " Please run 'make fmt' and commit the result:" ; \
26+ echo " $$ {diff}" ; \
27+ exit 1; \
28+ fi ;
29+
30+ .PHONY : lint
31+ lint : vet revive misspell
32+
33+ .PHONY : vet
34+ vet :
35+ $(GO ) vet $(GO_PACKAGE )
36+
37+ .PHONY : revive
38+ revive :
39+ $(GO ) get -u github.com/mgechev/revive; \
40+ revive -config .revive.toml || exit 1
41+
42+ .PHONY : misspell
43+ misspell-check :
44+ $(GO ) get -u github.com/client9/misspell/cmd/misspell; \
45+ misspell -error -i unknwon,destory $(GO_SOURCES )
46+
47+ .PHONY : test
48+ test :
49+ $(GO ) test -cover -coverprofile coverage.out || exit 1
Original file line number Diff line number Diff line change 11# Versioning Library for Go
22![ Build Status] ( https://github.com/6543/go-version/workflows/Release/badge.svg )
3+ [ ![ License: MPL] ( https://img.shields.io/badge/License-MPL2-red.svg )] ( https://opensource.org/licenses/MPL-2.0 )
34[ ![ GoDoc] ( https://godoc.org/github.com/6543/go-version?status.svg )] ( https://godoc.org/github.com/6543/go-version )
5+ [ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/6543/go-version )] ( https://goreportcard.com/report/github.com/6543/go-version )
46
57go-version is a library for parsing versions and version constraints,
68and verifying versions against a set of constraints. go-version
Original file line number Diff line number Diff line change @@ -195,10 +195,5 @@ func constraintPessimistic(v, c *Version) bool {
195195 // Check the last part of the segment in the constraint. If the version segment at
196196 // this index is less than the constraints segment at this index, then it cannot
197197 // be valid against the constraint
198- if c .segments [cs - 1 ] > v .segments [cs - 1 ] {
199- return false
200- }
201-
202- // If nothing has rejected the version by now, it's valid
203- return true
198+ return c .segments [cs - 1 ] <= v .segments [cs - 1 ]
204199}
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ func (v *Version) Compare(other *Version) int {
167167 // this means Other had the lower specificity
168168 // Check to see if the remaining segments in Self are all zeros -
169169 if ! allZero (segmentsSelf [i :]) {
170- //if not, it means that Self has to be greater than Other
170+ // if not, it means that Self has to be greater than Other
171171 return 1
172172 }
173173 break
@@ -262,7 +262,7 @@ func comparePrereleases(v string, other string) int {
262262 }
263263
264264 // loop for parts to find the first difference
265- for i := 0 ; i < biggestLen ; i = i + 1 {
265+ for i := 0 ; i < biggestLen ; i ++ {
266266 partSelfPre := ""
267267 if i < selfPreReleaseLen {
268268 partSelfPre = selfPreReleaseMeta [i ]
@@ -371,7 +371,7 @@ func (v *Version) String() string {
371371 str := strconv .FormatInt (s , 10 )
372372 fmtParts [i ] = str
373373 }
374- fmt .Fprintf (& buf , strings .Join (fmtParts , "." ))
374+ fmt .Fprint (& buf , strings .Join (fmtParts , "." ))
375375 if v .pre != "" {
376376 fmt .Fprintf (& buf , "-%s" , v .pre )
377377 }
You can’t perform that action at this time.
0 commit comments