From 702020a21f72f8c58b95da9b7da471917d137bc6 Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Sun, 28 Jan 2024 13:03:27 +0800 Subject: [PATCH] add go vet to CI --- .github/workflows/test.yml | 5 ++++- caddy/pmtiles_proxy.go | 4 ++-- main.go | 22 +++++++++++----------- pmtiles/extract.go | 2 -- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93adf11..62cde6c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: with: go-version: '^1.18.0' - run: go test ./pmtiles - fmt: + fmt_vet_lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -22,3 +22,6 @@ jobs: with: go-version: '^1.18.0' - run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi + - run: go vet caddy/pmtiles_proxy.go + - run: go vet main.go + - run: go vet pmtiles/* diff --git a/caddy/pmtiles_proxy.go b/caddy/pmtiles_proxy.go index 4b00522..0c2cb6d 100644 --- a/caddy/pmtiles_proxy.go +++ b/caddy/pmtiles_proxy.go @@ -45,7 +45,7 @@ func (m *Middleware) Provision(ctx caddy.Context) error { m.logger = ctx.Logger() logger := log.New(io.Discard, "", log.Ldate) prefix := "." // serve only the root of the bucket for now, at the root route of Caddyfile - server, err := pmtiles.NewServer(m.Bucket, prefix, logger, m.CacheSize, "", m.PublicUrl) + server, err := pmtiles.NewServer(m.Bucket, prefix, logger, m.CacheSize, "", m.PublicURL) if err != nil { return err } @@ -96,7 +96,7 @@ func (m *Middleware) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { } m.CacheSize = num case "public_url": - if !d.Args(&m.PublicUrl) { + if !d.Args(&m.PublicURL) { return d.ArgErr() } } diff --git a/main.go b/main.go index 4ae8081..b9cf4ad 100644 --- a/main.go +++ b/main.go @@ -53,11 +53,11 @@ var cli struct { Bucket string `help:"Remote bucket of input archive."` Region string `help:"local GeoJSON Polygon or MultiPolygon file for area of interest." type:"existingfile"` Bbox string `help:"bbox area of interest: min_lon,min_lat,max_lon,max_lat" type:"string"` - Minzoom int8 `default:-1 help:"Minimum zoom level, inclusive."` - Maxzoom int8 `default:-1 help:"Maximum zoom level, inclusive."` - DownloadThreads int `default:4 help:"Number of download threads."` + Minzoom int8 `default:"-1" help:"Minimum zoom level, inclusive."` + Maxzoom int8 `default:"-1" help:"Maximum zoom level, inclusive."` + DownloadThreads int `default:"4" help:"Number of download threads."` DryRun bool `help:"Calculate tiles to extract, but don't download them."` - Overfetch float32 `default:0.05 help:"What ratio of extra data to download to minimize # requests; 0.2 is 20%"` + Overfetch float32 `default:"0.05" help:"What ratio of extra data to download to minimize # requests; 0.2 is 20%"` } `cmd:"" help:"Create an archive from a larger archive for a subset of zoom levels or geographic region."` Verify struct { @@ -66,8 +66,8 @@ var cli struct { Makesync struct { Input string `arg:"" type:"existingfile"` - BlockSizeKb int `default:1000 help:"The approximate block size, in kilobytes. 0 means 1 tile = 1 block."` - HashFunction string `default:fnv1a help:"The hash function."` + BlockSizeKb int `default:"1000" help:"The approximate block size, in kilobytes. 0 means 1 tile = 1 block."` + HashFunction string `default:"fnv1a" help:"The hash function."` Checksum string `help:"Store a checksum in the syncfile."` } `cmd:"" hidden:""` @@ -79,9 +79,9 @@ var cli struct { Serve struct { Path string `arg:"" help:"Local path or bucket prefix"` Interface string `default:"0.0.0.0"` - Port int `default:8080` + Port int `default:"8080"` Cors string `help:"Value of HTTP CORS header."` - CacheSize int `default:64 help:"Size of cache in Megabytes."` + CacheSize int `default:"64" help:"Size of cache in Megabytes."` Bucket string `help:"Remote bucket"` PublicURL string `help:"Public base URL of tile endpoint for TileJSON e.g. https://example.com/tiles/"` } `cmd:"" help:"Run an HTTP proxy server for Z/X/Y tiles."` @@ -90,15 +90,15 @@ var cli struct { OldFile string `type:"existingfile" help:"The old archive on disk. Providing this will check the new archive for a .sync file"` NewFile string `arg:"The remote file."` Bucket string `required:"" help:"Bucket of file to download."` - DownloadThreads int `default:4 help:"Number of download threads."` + DownloadThreads int `default:"4" help:"Number of download threads."` DryRun bool `help:"Calculate new parts to download, but don't download them."` - Overfetch float32 `default:0.05 help:"What ratio of extra data to download to minimize # requests; 0.2 is 20%"` + Overfetch float32 `default:"0.05" help:"What ratio of extra data to download to minimize # requests; 0.2 is 20%"` } `cmd:"" help:"Upload a local archive to remote storage."` Upload struct { Input string `arg:"" type:"existingfile"` Key string `arg:""` - MaxConcurrency int `default:2 help:"# of upload threads"` + MaxConcurrency int `default:"2" help:"# of upload threads"` Bucket string `required:"" help:"Bucket to upload to."` } `cmd:"" help:"Upload a local archive to remote storage."` diff --git a/pmtiles/extract.go b/pmtiles/extract.go index d06e5d1..0c14bd4 100644 --- a/pmtiles/extract.go +++ b/pmtiles/extract.go @@ -543,8 +543,6 @@ func Extract(_ *log.Logger, bucketURL string, key string, minzoom int8, maxzoom return err } } - - return nil }) }