Skip to content

Commit

Permalink
Merge pull request #38 from twpayne/update-deps
Browse files Browse the repository at this point in the history
Miscellaneous updates
  • Loading branch information
twpayne authored Oct 2, 2024
2 parents eee7416 + f776433 commit bd760a3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
- run: go build ./...
- run: go test ./...
Expand All @@ -21,8 +21,8 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
- uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64
- uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86
with:
version: v1.59.1
version: v1.61.0
11 changes: 7 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
run:
go: '1.22'

linters:
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- decorder
- dogsled
- dupl
Expand All @@ -17,7 +22,6 @@ linters:
- errname
- errorlint
- exhaustive
- exportloopref
- fatcontext
- forbidigo
- forcetypeassert
Expand Down Expand Up @@ -47,6 +51,7 @@ linters:
- inamedparam
- ineffassign
- interfacebloat
- intrange
- ireturn
- loggercheck
- makezero
Expand Down Expand Up @@ -77,6 +82,7 @@ linters:
- tagalign
- tagliatelle
- tenv
- testableexamples
- testifylint
- testpackage
- thelper
Expand All @@ -90,7 +96,6 @@ linters:
- whitespace
- zerologlint
disable:
- canonicalheader
- cyclop
- depguard
- exhaustruct
Expand All @@ -102,7 +107,6 @@ linters:
- maintidx
- nlreturn
- paralleltest
- testableexamples
- varnamelen
- wrapcheck
- wsl
Expand All @@ -115,7 +119,6 @@ linters-settings:
- prefix(github.com/twpayne/go-kml)
gofumpt:
extra-rules: true
local-prefixes: github.com/twpayne/go-kml
goimports:
local-prefixes: github.com/twpayne/go-kml
govet:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/twpayne/go-kml/v3

go 1.21
go 1.22

require (
github.com/alecthomas/assert/v2 v2.10.0
Expand Down
29 changes: 28 additions & 1 deletion kmz_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package kml_test

import (
"archive/zip"
"bytes"
"fmt"
"io"
"os"

"github.com/twpayne/go-kml/v3"
Expand All @@ -18,9 +22,32 @@ func ExampleWriteKMZ() {
),
)

if err := kml.WriteKMZ(os.Stdout, map[string]any{
var buffer bytes.Buffer
buffer.Grow(512)
if err := kml.WriteKMZ(&buffer, map[string]any{
"doc.kml": doc,
}); err != nil {
panic(err)
}

zipReader, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(buffer.Len()))
if err != nil {
panic(err)
}
for _, zipFile := range zipReader.File {
fmt.Println(zipFile.Name + ":")
file, err := zipFile.Open()
if err != nil {
panic(err)
}
if _, err := io.Copy(os.Stdout, file); err != nil { //nolint:gosec
panic(err)
}
file.Close()
}

// Output:
// doc.kml:
// <?xml version="1.0" encoding="UTF-8"?>
// <kml xmlns="http://www.opengis.net/kml/2.2"><Placemark><name>Zürich</name><Point><coordinates>8.541111,47.374444</coordinates></Point></Placemark></kml>
}
2 changes: 1 addition & 1 deletion sphere/sphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (t T) Offset(origin kml.Coordinate, distance, bearing float64) kml.Coordina
func (t T) Circle(center kml.Coordinate, radius, maxErr float64) []kml.Coordinate {
numVertices := int(math.Ceil(math.Pi / math.Acos((radius-maxErr)/(radius+maxErr))))
cs := make([]kml.Coordinate, numVertices+1)
for i := 0; i < numVertices; i++ {
for i := range numVertices {
cs[i] = t.Offset(center, radius, 360*float64(i)/float64(numVertices))
}
cs[numVertices] = cs[0]
Expand Down

0 comments on commit bd760a3

Please sign in to comment.