Skip to content

Commit

Permalink
Merge pull request #244 from twpayne/update-deps
Browse files Browse the repository at this point in the history
Update project infrastructure
  • Loading branch information
twpayne committed Mar 12, 2024
2 parents ea92778 + 0ef9444 commit 434fec1
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 64 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ on:
pull_request:
push:
env:
GOFUMPT_VERSION: 0.3.1
GOFUMPT_VERSION: 0.6.0
GOLANGCI_LINT_VERSION: 1.56.2
jobs:
linux:
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
48 changes: 46 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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:
Expand Down
18 changes: 9 additions & 9 deletions bigxy/big_cga.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions encoding/ewkbhex/ewkbhex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ewkbhex

import (
"encoding/hex"
"fmt"
"testing"

"github.com/alecthomas/assert/v2"
Expand Down Expand Up @@ -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)
})
}
Expand Down
6 changes: 3 additions & 3 deletions encoding/geojson/geojson.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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 {
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion encoding/igc/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
3 changes: 2 additions & 1 deletion encoding/wkb/wkb.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package wkb
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"io"

Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions encoding/wkbhex/wkbhex_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package wkbhex

import (
"fmt"
"testing"

"github.com/alecthomas/assert/v2"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion encoding/wkt/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions encoding/wkt/lex_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions encoding/wkt/wkt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
^`,
},
{
Expand All @@ -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
^`,
},
{
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 434fec1

Please sign in to comment.