Skip to content

Commit

Permalink
Merge pull request #116 from twpayne/misc-fixes
Browse files Browse the repository at this point in the history
Miscellaneous fixes
  • Loading branch information
twpayne authored Jan 15, 2024
2 parents acfb301 + d3edf59 commit 51a00a8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc
with:
version: v1.54.2
version: v1.55.2
geos-versions:
strategy:
fail-fast: false
Expand Down
19 changes: 12 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ linters:
- forbidigo
- forcetypeassert
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecknoinits
- goconst
- gochecksumtype
- gocritic
- godot
- goerr113
- gofmt
- gofumpt
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
Expand All @@ -37,10 +39,12 @@ linters:
- govet
- grouper
- importas
- inamedparam
- ineffassign
- interfacebloat
- ireturn
- loggercheck
- makezero
- mirror
- misspell
- musttag
Expand All @@ -50,18 +54,23 @@ linters:
- noctx
- nolintlint
- nosprintfhostport
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- rowserrcheck
- sloglint
- sqlclosecheck
- staticcheck
- stylecheck
- tagalign
- tagliatelle
- tenv
- testableexamples
- testifylint
- testpackage
- thelper
- typecheck
Expand All @@ -71,34 +80,30 @@ linters:
- usestdlibvars
- wastedassign
- whitespace
- zerologlint
disable:
- cyclop
- depguard
- dupl
- exhaustivestruct
- exhaustruct
- funlen
- ginkgolinter
- gochecknoglobals
- gocognit
- goconst
- gocyclo
- godox
- goheader
- gomnd
- gomoddirectives
- lll
- maintidx
- makezero
- nestif
- nlreturn
- nonamedreturns
- paralleltest
- revive
- tparallel
- varnamelen
- wrapcheck
- wsl
- zerologlint

linters-settings:
gci:
Expand Down
5 changes: 4 additions & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
type Context struct {
sync.Mutex
handle C.GEOSContextHandle_t
ewkbWriter *C.struct_GEOSWKBWriter_t
ewkbWithSRIDWriter *C.struct_GEOSWKBWriter_t
geoJSONReader *C.struct_GEOSGeoJSONReader_t
geoJSONWriter *C.struct_GEOSGeoJSONWriter_t
wkbReader *C.struct_GEOSWKBReader_t
Expand Down Expand Up @@ -376,6 +376,9 @@ func (c *Context) cGeomsLocked(geoms []*Geom) (**C.struct_GEOSGeom_t, func()) {
func (c *Context) finish() {
c.Lock()
defer c.Unlock()
if c.ewkbWithSRIDWriter != nil {
C.GEOSWKBWriter_destroy_r(c.handle, c.ewkbWithSRIDWriter)
}
if c.geoJSONReader != nil {
C.GEOSGeoJSONReader_destroy_r(c.handle, c.geoJSONReader)
}
Expand Down
2 changes: 1 addition & 1 deletion geojson/geojson.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (fc FeatureCollection) MarshalJSON() ([]byte, error) {
feature := feature{
ID: f.ID,
Type: featureType,
Geometry: &f.Geometry, //nolint:gosec
Geometry: &f.Geometry,
Properties: f.Properties,
}
features = append(features, feature)
Expand Down
10 changes: 5 additions & 5 deletions geom.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ func (g *Geom) ToEWKBWithSRID() []byte {
g.mustNotBeDestroyed()
g.context.Lock()
defer g.context.Unlock()
if g.context.ewkbWriter == nil {
g.context.ewkbWriter = C.GEOSWKBWriter_create_r(g.context.handle)
C.GEOSWKBWriter_setFlavor_r(g.context.handle, g.context.ewkbWriter, C.GEOS_WKB_EXTENDED)
C.GEOSWKBWriter_setIncludeSRID_r(g.context.handle, g.context.ewkbWriter, 1)
if g.context.ewkbWithSRIDWriter == nil {
g.context.ewkbWithSRIDWriter = C.GEOSWKBWriter_create_r(g.context.handle)
C.GEOSWKBWriter_setFlavor_r(g.context.handle, g.context.ewkbWithSRIDWriter, C.GEOS_WKB_EXTENDED)
C.GEOSWKBWriter_setIncludeSRID_r(g.context.handle, g.context.ewkbWithSRIDWriter, 1)
}
var size C.size_t
ewkbCBuf := C.GEOSWKBWriter_write_r(g.context.handle, g.context.ewkbWriter, g.geom, &size)
ewkbCBuf := C.GEOSWKBWriter_write_r(g.context.handle, g.context.ewkbWithSRIDWriter, g.geom, &size)
defer C.GEOSFree_r(g.context.handle, unsafe.Pointer(ewkbCBuf))
return C.GoBytes(unsafe.Pointer(ewkbCBuf), C.int(size))
}
Expand Down
2 changes: 1 addition & 1 deletion geometry/kml.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
)

// MarshalXML implements encoding/xml.Marshaler.
func (g *Geometry) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
func (g *Geometry) MarshalXML(e *xml.Encoder, _ xml.StartElement) error {
return kmlEncodeGeom(e, g.Geom)
}

Expand Down

0 comments on commit 51a00a8

Please sign in to comment.