From c46a217da5e700d5c3b07cc88be1efd8a3198fe7 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Mon, 4 Mar 2024 23:45:43 +0100 Subject: [PATCH 1/5] Update dependencies --- go.mod | 12 ++++++------ go.sum | 33 +++++++++++++++++---------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index aebec8ca..78683896 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.21 toolchain go1.22.1 require ( - github.com/DATA-DOG/go-sqlmock v1.5.0 - github.com/alecthomas/assert/v2 v2.4.0 + github.com/DATA-DOG/go-sqlmock v1.5.2 + github.com/alecthomas/assert/v2 v2.6.0 github.com/lib/pq v1.10.9 github.com/testcontainers/testcontainers-go v0.29.1 github.com/testcontainers/testcontainers-go/modules/postgres v0.29.1 @@ -15,10 +15,10 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect - github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/Microsoft/hcsshim v0.11.4 // indirect - github.com/alecthomas/repr v0.3.0 // indirect + github.com/alecthomas/repr v0.4.0 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/containerd/containerd v1.7.12 // indirect github.com/containerd/log v0.1.0 // indirect @@ -59,8 +59,8 @@ require ( go.opentelemetry.io/otel/trace v1.19.0 // indirect golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect golang.org/x/mod v0.16.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/tools v0.13.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect google.golang.org/grpc v1.58.3 // indirect google.golang.org/protobuf v1.31.0 // indirect diff --git a/go.sum b/go.sum index 0ec396ba..3a16e272 100644 --- a/go.sum +++ b/go.sum @@ -2,22 +2,22 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= +github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= github.com/alecthomas/assert v1.0.0 h1:3XmGh/PSuLzDbK3W2gUbRXwgW5lqPkuqvRgeQ30FI5o= github.com/alecthomas/assert v1.0.0/go.mod h1:va/d2JC+M7F6s+80kl/R3G7FUiW6JzUO+hPhLyJ36ZY= -github.com/alecthomas/assert/v2 v2.4.0 h1:/ZiZ0NnriAWPYYO+4eOjgzNELrFQLaHNr92mHSHFj9U= -github.com/alecthomas/assert/v2 v2.4.0/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM= +github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU= +github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/colour v0.1.0 h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk= github.com/alecthomas/colour v0.1.0/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= -github.com/alecthomas/repr v0.3.0 h1:NeYzUPfjjlqHY4KtzgKJiWd6sVq2eNUPTi34PiFGjY8= -github.com/alecthomas/repr v0.3.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= +github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/containerd/containerd v1.7.12 h1:+KQsnv4VnzyxWcfO9mlxxELaoztsDEjOuCMPAuPqgU0= @@ -72,6 +72,7 @@ github.com/jackc/pgx/v5 v5.5.4 h1:Xp2aQS8uXButQdnCMWNmvx6UysWQQC+u1EoizjguY+8= github.com/jackc/pgx/v5 v5.5.4/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= @@ -166,13 +167,13 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -183,8 +184,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= @@ -195,8 +196,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From cd2832fc0a16a95ad6e04875390bfdaeb8e884b6 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Mon, 4 Mar 2024 23:46:02 +0100 Subject: [PATCH 2/5] Update GitHub Actions --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e9d202a8..48e28305 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: cache: true go-version-file: go.mod @@ -30,7 +30,7 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: cache: true go-version-file: go.mod @@ -42,7 +42,7 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: cache: true go-version-file: go.mod @@ -54,11 +54,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: cache: true go-version-file: go.mod - - uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc + - uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 with: version: v${{ env.GOLANGCI_LINT_VERSION }} - name: format From f772a88a980e0f7efad85978e996b054e5ac1f75 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 5 Mar 2024 00:02:40 +0100 Subject: [PATCH 3/5] Update golangci-lint --- .golangci.yml | 48 +++++++++++++++++++++++++++++-- bigxy/big_cga.go | 18 ++++++------ encoding/ewkbhex/ewkbhex_test.go | 3 +- encoding/geojson/geojson.go | 6 ++-- encoding/igc/decode.go | 2 +- encoding/wkb/wkb.go | 3 +- encoding/wkbhex/wkbhex_test.go | 5 ++-- encoding/wkt/lex.go | 2 +- encoding/wkt/lex_errors.go | 4 +-- encoding/wkt/wkt_test.go | 10 +++---- linearring.go | 2 +- sorting/sorting.go | 7 +++-- xy/internal/hcoords/hcoords.go | 6 ++-- xy/line_centroid_examples_test.go | 1 + 14 files changed, 81 insertions(+), 36 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 275161aa..fa6a0504 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,17 +1,28 @@ linters: enable: + - asasalint - asciicheck + - bidichk - bodyclose + - containedctx + - contextcheck + - decorder - dogsled - dupl + - dupword - durationcheck - errcheck + - errchkjson - errorlint + - execinquery - exportloopref - forbidigo - forcetypeassert - gci + - ginkgolinter + - gocheckcompilerdirectives - gochecknoinits + - gochecksumtype - gocritic - godot - goerr113 @@ -23,37 +34,58 @@ linters: - goprintffuncname - gosec - gosimple + - gosmopolitan - govet + - grouper - importas + - inamedparam - ineffassign + - interfacebloat + - ireturn + - loggercheck - makezero + - mirror - misspell + - musttag - nakedret - nilerr + - nilnil - noctx - nolintlint + - nosprintfhostport + - perfsprint - prealloc - predeclared - promlinter + - protogetter + - reassign - revive - rowserrcheck + - sloglint + - spancheck - sqlclosecheck - staticcheck - stylecheck + - tagalign - tagliatelle + - tenv + - testableexamples + - testifylint - thelper - tparallel - typecheck - unconvert - unparam - unused - - wastedassign + - usestdlibvars - whitespace + - zerologlint disable: - cyclop - depguard + - errname # FIXME renaming ErrXxx to XxxError will require a major version bump - exhaustive - - exhaustivestruct + - exhaustruct - funlen - gochecknoglobals - gocognit @@ -63,10 +95,16 @@ linters: - goheader - gomnd - lll + - maintidx - nestif - nlreturn + - nonamedreturns - paralleltest + - paralleltest + - testpackage - testpackage + - varnamelen + - wastedassign # https://github.com/golangci/golangci-lint/issues/2649 - wrapcheck - wsl @@ -78,6 +116,12 @@ linters-settings: - prefix(github.com/twpayne/go-geom) goimports: local-prefixes: github.com/twpayne/go-geom + ireturn: + allow: + - error + - stdlib + - ^github\.com/twpayne/go-geom\.T$ + - ^github\.com/twpayne/go-kml/v3\.Element$ issues: exclude-rules: diff --git a/bigxy/big_cga.go b/bigxy/big_cga.go index 7318d561..ab32a3a2 100644 --- a/bigxy/big_cga.go +++ b/bigxy/big_cga.go @@ -17,16 +17,16 @@ import ( // relative round-off error in big.Float precision numbers var dpSafeEpsilon = 1e-15 -// OrientationIndex returns the index of the direction of the point point relative to -// a vector specified by vectorOrigin-vectorEnd +// OrientationIndex returns the index of the direction of point relative +// to a vector specified by vectorOrigin-vectorEnd // -// vectorOrigin - the origin point of the vector -// vectorEnd - the final point of the vector -// point - the point to compute the direction to +// vectorOrigin - the origin point of the vector vectorEnd - the final point of +// the vector point - the point to compute the direction to // -// Returns CounterClockwise if point is counter-clockwise (left) from vectorOrigin-vectorEnd -// Returns Clockwise if point is clockwise (right) from vectorOrigin-vectorEnd -// Returns Collinear if point is collinear with vectorOrigin-vectorEnd +// Returns CounterClockwise if point is counter-clockwise (left) from +// vectorOrigin-vectorEnd. Returns Clockwise if point is clockwise (right) from +// vectorOrigin-vectorEnd. Returns Collinear if point is collinear with +// vectorOrigin-vectorEnd. func OrientationIndex(vectorOrigin, vectorEnd, point geom.Coord) orientation.Type { // fast filter for orientation index // avoids use of slow extended-precision arithmetic in many cases @@ -52,7 +52,7 @@ func OrientationIndex(vectorOrigin, vectorEnd, point geom.Coord) orientation.Typ } // Intersection computes the intersection point of the two lines using math.big.Float arithmetic. -// The lines are considered infinate in length. For example, (0,0), (1, 0) and (2, 1) (2, 2) will have intersection of (2, 0) +// The lines are considered infinite in length. For example, (0,0), (1, 0) and (2, 1) (2, 2) will have intersection of (2, 0) // Currently does not handle case of parallel lines. func Intersection(line1Start, line1End, line2Start, line2End geom.Coord) geom.Coord { var denom1, denom2, denom, tmp1, tmp2 big.Float diff --git a/encoding/ewkbhex/ewkbhex_test.go b/encoding/ewkbhex/ewkbhex_test.go index 3a0c491c..ef31346e 100644 --- a/encoding/ewkbhex/ewkbhex_test.go +++ b/encoding/ewkbhex/ewkbhex_test.go @@ -2,7 +2,6 @@ package ewkbhex import ( "encoding/hex" - "fmt" "testing" "github.com/alecthomas/assert/v2" @@ -215,7 +214,7 @@ func Test(t *testing.T) { xdr: "0020000003000010e60000000100000005c05314cc94c5c52c40440619d4a35817c05314cbfce5c52c4044061ca33b581bc05314c9819fc5294044061b580f5817c05314ca197fc52b4044061891335816c05314cc94c5c52c40440619d4a35817", }, } { - t.Run(fmt.Sprintf("ndr:%s", tc.ndr), func(t *testing.T) { + t.Run("ndr:"+tc.ndr, func(t *testing.T) { test(t, tc.g, tc.xdr, tc.ndr) }) } diff --git a/encoding/geojson/geojson.go b/encoding/geojson/geojson.go index 996f8bb5..748fe3ac 100644 --- a/encoding/geojson/geojson.go +++ b/encoding/geojson/geojson.go @@ -28,7 +28,7 @@ func (e ErrDimensionalityTooLow) Error() string { type ErrUnsupportedType string func (e ErrUnsupportedType) Error() string { - return fmt.Sprintf("geojson: unsupported type: %s", string(e)) + return "geojson: unsupported type: " + string(e) } // CRS is a deprecated field but still populated in some programs (e.g. PostGIS). @@ -332,7 +332,7 @@ func EncodeGeometryWithMaxDecimalDigits(maxDecimalDigits int) EncodeGeometryOpti // Encode encodes g as a GeoJSON geometry. func Encode(g geom.T, opts ...EncodeGeometryOption) (*Geometry, error) { if g == nil { - return nil, nil + return nil, nil //nolint:nilnil } ret, err := encode(g, opts...) if err != nil { @@ -351,7 +351,7 @@ func Encode(g geom.T, opts ...EncodeGeometryOption) (*Geometry, error) { // encode encodes the geometry assuming it is not nil. func encode(g geom.T, opts ...EncodeGeometryOption) (*Geometry, error) { if g == nil { - return nil, nil + return nil, nil //nolint:nilnil } switch g := g.(type) { case *geom.Point: diff --git a/encoding/igc/decode.go b/encoding/igc/decode.go index 21b8fd65..e2ae47af 100644 --- a/encoding/igc/decode.go +++ b/encoding/igc/decode.go @@ -204,7 +204,7 @@ func (p *parser) parseB(line string) error { func (p *parser) parseH(line string) error { m := hRegexp.FindStringSubmatch(line) if m == nil { - return fmt.Errorf("invalid H record") + return errors.New("invalid H record") } header := Header{ Source: m[1], diff --git a/encoding/wkb/wkb.go b/encoding/wkb/wkb.go index 481cb090..b12f91bc 100644 --- a/encoding/wkb/wkb.go +++ b/encoding/wkb/wkb.go @@ -8,6 +8,7 @@ package wkb import ( "bytes" "encoding/binary" + "errors" "fmt" "io" @@ -265,7 +266,7 @@ func Write(w io.Writer, byteOrder binary.ByteOrder, g geom.T, opts ...wkbcommon. case wkbcommon.EmptyPointHandlingNaN: return wkbcommon.WriteEmptyPointAsNaN(w, byteOrder, g.Stride()) case wkbcommon.EmptyPointHandlingError: - return fmt.Errorf("cannot encode empty Point in WKB") + return errors.New("cannot encode empty Point in WKB") default: return fmt.Errorf("cannot encode empty Point in WKB (unknown option: %d)", wkbcommon.EmptyPointHandlingNaN) } diff --git a/encoding/wkbhex/wkbhex_test.go b/encoding/wkbhex/wkbhex_test.go index 8ada33e4..cd42e240 100644 --- a/encoding/wkbhex/wkbhex_test.go +++ b/encoding/wkbhex/wkbhex_test.go @@ -1,7 +1,6 @@ package wkbhex import ( - "fmt" "testing" "github.com/alecthomas/assert/v2" @@ -154,7 +153,7 @@ func Test(t *testing.T) { }, } { if tc.ndr != "" { - t.Run(fmt.Sprintf("ndr:%s", tc.ndr), func(t *testing.T) { + t.Run("ndr:"+tc.ndr, func(t *testing.T) { t.Run("encode", func(t *testing.T) { got, err := Encode(tc.g, wkb.NDR, tc.opts...) assert.NoError(t, err) @@ -168,7 +167,7 @@ func Test(t *testing.T) { }) } if tc.xdr != "" { - t.Run(fmt.Sprintf("xdr:%s", tc.xdr), func(t *testing.T) { + t.Run("xdr:"+tc.xdr, func(t *testing.T) { t.Run("encode", func(t *testing.T) { got, err := Encode(tc.g, wkb.XDR, tc.opts...) assert.NoError(t, err) diff --git a/encoding/wkt/lex.go b/encoding/wkt/lex.go index e0cb293d..e7b59ed5 100644 --- a/encoding/wkt/lex.go +++ b/encoding/wkt/lex.go @@ -384,7 +384,7 @@ func (l *wktLex) nextScannedPointMustBeEmpty() bool { // setLexError is called by Lex when a lexing (tokenizing) error is detected. func (l *wktLex) setLexError(expectedTokType string) { - l.Error(fmt.Sprintf("invalid %s", expectedTokType)) + l.Error("invalid " + expectedTokType) } // setParseError is called when a context-sensitive error is detected during parsing. diff --git a/encoding/wkt/lex_errors.go b/encoding/wkt/lex_errors.go index bf9055f3..9df396cd 100644 --- a/encoding/wkt/lex_errors.go +++ b/encoding/wkt/lex_errors.go @@ -59,11 +59,11 @@ func (e *SyntaxError) Error() string { snippet := e.wkt[snipStart:snipEnd] snippet = strings.ReplaceAll(snippet, "\t", " ") err += strLinePrefix + snippet + strLineSuffix - err += fmt.Sprintf("%s^", strings.Repeat(" ", len(strLinePrefix)+snipPos)) + err += strings.Repeat(" ", len(strLinePrefix)+snipPos) + "^" // Print a hint, if applicable. if e.hint != "" { - err += fmt.Sprintf("\nHINT: %s", e.hint) + err += "\nHINT: " + e.hint } return err diff --git a/encoding/wkt/wkt_test.go b/encoding/wkt/wkt_test.go index ab2265ea..f055e95d 100644 --- a/encoding/wkt/wkt_test.go +++ b/encoding/wkt/wkt_test.go @@ -939,12 +939,12 @@ LINE 1: POINT Z M (1 1 1 1) desc: "invalid geometry type split over multiple lines", input: `POINT Z - Z ( + M ( 0 0 )`, expectedErrStr: `syntax error: invalid keyword at line 3, pos 7 -LINE 3: Z ( +LINE 3: M ( ^`, }, { @@ -964,9 +964,9 @@ LINE 1: ..., 0 0, 0 0, 0 0, 0 0, 0 0, 0 0} // ParseError { desc: "invalid point", - input: "POINT POINT", - expectedErrStr: `syntax error: unexpected POINT, expecting '(' at line 1, pos 6 -LINE 1: POINT POINT + input: "POINT P", + expectedErrStr: `syntax error: invalid keyword at line 1, pos 6 +LINE 1: POINT P ^`, }, { diff --git a/linearring.go b/linearring.go index 44fb7ab7..d46dae57 100644 --- a/linearring.go +++ b/linearring.go @@ -19,7 +19,7 @@ func NewLinearRingFlat(layout Layout, flatCoords []float64) *LinearRing { return g } -// Area returns the the area. +// Area returns the area. func (g *LinearRing) Area() float64 { return doubleArea1(g.flatCoords, 0, len(g.flatCoords), g.stride) / 2 } diff --git a/sorting/sorting.go b/sorting/sorting.go index 1ceffdd9..69e373f1 100644 --- a/sorting/sorting.go +++ b/sorting/sorting.go @@ -2,10 +2,11 @@ package sorting import "github.com/twpayne/go-geom" -// FlatCoord is a sort.Interface implementation that will result in sorting the wrapped coords based on the -// the comparator function +// FlatCoord is a sort.Interface implementation that will result in sorting the +// wrapped coords based on the comparator function // -// Note: this data struct cannot be used with its 0 values. it must be constructed using NewFlatCoordSorting +// Note: this data struct cannot be used with its 0 values. it must be +// constructed using NewFlatCoordSorting type FlatCoord struct { isLess IsLess coords []float64 diff --git a/xy/internal/hcoords/hcoords.go b/xy/internal/hcoords/hcoords.go index 83734fb3..d8ba8af9 100644 --- a/xy/internal/hcoords/hcoords.go +++ b/xy/internal/hcoords/hcoords.go @@ -1,7 +1,7 @@ package hcoords import ( - "fmt" + "errors" "math" "github.com/twpayne/go-geom" @@ -31,11 +31,11 @@ func GetIntersection(line1End1, line1End2, line2End1, line2End2 geom.Coord) (geo yIntersection := y / w if math.IsNaN(xIntersection) || math.IsNaN(yIntersection) { - return nil, fmt.Errorf("intersection cannot be calculated using the h-coords implementation") + return nil, errors.New("intersection cannot be calculated using the h-coords implementation") } if math.IsInf(xIntersection, 0) || math.IsInf(yIntersection, 0) { - return nil, fmt.Errorf("intersection cannot be calculated using the h-coords implementation") + return nil, errors.New("intersection cannot be calculated using the h-coords implementation") } return geom.Coord{xIntersection, yIntersection}, nil diff --git a/xy/line_centroid_examples_test.go b/xy/line_centroid_examples_test.go index b05e7680..c5eb623d 100644 --- a/xy/line_centroid_examples_test.go +++ b/xy/line_centroid_examples_test.go @@ -20,6 +20,7 @@ func ExampleLinearRingsCentroid() { line2 := geom.NewLinearRingFlat(geom.XY, []float64{10, 10, 11, 11, 13, 13, 10, 10}) centroid := xy.LinearRingsCentroid(line1, line2) fmt.Println(centroid) + // Output: [6.499999999999999 6.499999999999999] } func ExampleMultiLineCentroid() { From 8747b158aa741bc77b38928b58661ed8d942847c Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 5 Mar 2024 00:14:09 +0100 Subject: [PATCH 4/5] Update gofumpt --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 48e28305..1126a9b3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ on: pull_request: push: env: - GOFUMPT_VERSION: 0.3.1 + GOFUMPT_VERSION: 0.6.0 GOLANGCI_LINT_VERSION: 1.56.2 jobs: linux: From 0ef9444b39047efc15b50344bd91ebb2850fdc1f Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 12 Mar 2024 20:45:06 +0100 Subject: [PATCH 5/5] Fix test --- xy/line_centroid_examples_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xy/line_centroid_examples_test.go b/xy/line_centroid_examples_test.go index c5eb623d..e0fd390b 100644 --- a/xy/line_centroid_examples_test.go +++ b/xy/line_centroid_examples_test.go @@ -20,7 +20,7 @@ func ExampleLinearRingsCentroid() { line2 := geom.NewLinearRingFlat(geom.XY, []float64{10, 10, 11, 11, 13, 13, 10, 10}) centroid := xy.LinearRingsCentroid(line1, line2) fmt.Println(centroid) - // Output: [6.499999999999999 6.499999999999999] + // Output: [6.5 6.5] } func ExampleMultiLineCentroid() {