Skip to content

Commit

Permalink
chore: upgrade to Go 1.20 (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
mojixcoder authored Aug 29, 2024
1 parent 065469a commit 1ce71fc
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,33 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.18"]
go-version: ["1.20"]

steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.47.3
version: v1.60.3

test:
name: test
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.18", "1.19"]
go-version:
- "1.20"
- "1.21"
- "1.22"

steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: unit-tests
run: |
go test -count=2 -race -covermode atomic -coverprofile=covprofile ./...
Expand Down
16 changes: 9 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,35 @@ linters-settings:
- performance
- style
govet:
check-shadowing: true
enable-all: true
nolintlint:
require-explanation: true
require-specific: true
wsl:
allow-assign-and-anything: true
allow-cuddle-declarations: true
allow-assign-and-call: true
depguard:
rules:
main:
list-mode: lax
allow:
- "github.com/uber/h3-go/v4"

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- exportloopref
# - copyloopvar Enable this after upgrading go version to 1.22
- exhaustive
- goconst
# - gocritic
- gofmt
- goimports
- gomnd
- mnd
- gocyclo
- gosec
- gosimple
Expand All @@ -49,14 +53,12 @@ linters:
- predeclared
- revive
- staticcheck
- structcheck
- stylecheck
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- varcheck
- whitespace
- wsl

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func ExampleLatLngToCell() {
| `originToDirectedEdges` | `Cell#DirectedEdges` |
| `directedEdgeToBoundary` | `DirectedEdge#Boundary` |
| `cellToVertex` | `CellToVertex` |
| `cellToVertexes` | `cellToVertexes` |
| `cellToVertexes` | `CellToVertexes` |
| `vertexToLatLng` | `VertexToLatLng` |
| `isValidVertex` | `IsValidVertex` |
| `gridDistance` | `GridDistance`, `Cell#GridDistance` |
Expand Down
1 change: 1 addition & 0 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func BenchmarkToString(b *testing.B) {

func BenchmarkFromString(b *testing.B) {
for n := 0; n < b.N; n++ {
//nolint:gosec // IndexFromString returns uint64 and fixing that to detect integer overflows will break package API. Let's skip it for now.
cell = Cell(IndexFromString("850dab63fffffff"))
}
}
Expand Down
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/uber/h3-go/v4

go 1.18
go 1.20
4 changes: 2 additions & 2 deletions h3.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func EdgeLengthM(e DirectedEdge) float64 {
func NumCells(resolution int) int {
// NOTE: this is a mathematical operation, no need to call into H3 library.
// See h3api.h for formula derivation.
return 2 + 120*intPow(7, (resolution)) //nolint:gomnd // math formula
return 2 + 120*intPow(7, (resolution)) //nolint:mnd // math formula
}

// Res0Cells returns all the cells at resolution 0.
Expand Down Expand Up @@ -765,7 +765,7 @@ func ringSize(k int) int {
return 1
}

return 6 * k //nolint:gomnd // math formula
return 6 * k //nolint:mnd // math formula
}

// Convert slice of LatLngs to an array of C LatLngs (represented in C-style as
Expand Down
8 changes: 8 additions & 0 deletions h3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ func TestStrings(t *testing.T) {
t.Run("good string round trip", func(t *testing.T) {
t.Parallel()
i := IndexFromString(validCell.String())

//nolint:gosec // IndexFromString returns uint64 and fixing that to detect integer overflows will break package API. Let's skip it for now.
assertEqual(t, validCell, Cell(i))
})

Expand Down Expand Up @@ -612,8 +614,10 @@ func TestPentagons(t *testing.T) {
res := res
t.Run(fmt.Sprintf("res=%d", res), func(t *testing.T) {
t.Parallel()

pentagons := Pentagons(res)
assertEqual(t, 12, len(pentagons))

for _, pentagon := range pentagons {
assertTrue(t, pentagon.IsPentagon())
assertEqual(t, res, pentagon.Resolution())
Expand Down Expand Up @@ -737,6 +741,7 @@ func assertEqual[T comparable](t *testing.T, expected, actual T, msgAndArgs ...i
expStr = fmt.Sprintf("%v", e)
actStr = fmt.Sprintf("%v", a)
}

t.Errorf("%v != %v", expStr, actStr)
logMsgAndArgs(t, msgAndArgs...)
}
Expand Down Expand Up @@ -779,6 +784,7 @@ func assertEqualLatLngs(t *testing.T, expected, actual []LatLng, msgAndArgs ...i

t.Errorf("LatLngs[%d]: (%s, %s)", i, latStr, lngStr)
logMsgAndArgs(t, msgAndArgs...)

count++

if count > 10 {
Expand Down Expand Up @@ -808,6 +814,7 @@ func assertEqualCells(t *testing.T, expected, actual []Cell, msgAndArgs ...inter
if c != actual[i] {
t.Errorf("Cells[%d]: %v != %v", i, c, actual[i])
logMsgAndArgs(t, msgAndArgs...)

count++

if count > 10 {
Expand Down Expand Up @@ -863,6 +870,7 @@ func assertEqualDisks(t *testing.T, expected, actual []Cell) {
for i, cell := range expected {
if cell != actual[i] {
t.Errorf("cell[%d]: %v != %v", i, cell, actual[i])

count++

if count > 5 {
Expand Down

0 comments on commit 1ce71fc

Please sign in to comment.