From 510ebdf3b9fb6da9e188ade994022dace430efee Mon Sep 17 00:00:00 2001 From: Callum Morris Date: Mon, 20 May 2024 14:41:05 +1200 Subject: [PATCH] style: run goimports --- cfg/cfg_test.go | 3 +- datalogger_pb/datalogger.pb.go | 7 +++-- fmp_pb/fmp.pb.go | 7 +++-- gloria_pb/gloria.pb.go | 5 +-- haz_pb/haz.pb.go | 5 +-- map180/bbox.go | 6 ++-- map180/map.go | 55 ++++++++++++++++----------------- map180/nzmap/nzmap.go | 19 ++++++------ metrics/counters_test.go | 3 +- metrics/timers_test.go | 3 +- sc3ml/sc3ml_integration_test.go | 2 +- seis/dl/doc.go | 1 - seis/ms/doc.go | 1 - seis/ms/header.go | 1 + seis/ms/record.go | 2 +- seis/ms/steim.go | 4 +-- seis/sl/conn_test.go | 1 + seis/sl/doc.go | 13 ++++---- seis/sl/slink_test.go | 1 + weft/handlers_test.go | 3 +- weft/weft.go | 6 ++-- weft/weft_test.go | 3 +- weft/wefttest/wefttest_test.go | 5 +-- 23 files changed, 82 insertions(+), 74 deletions(-) diff --git a/cfg/cfg_test.go b/cfg/cfg_test.go index 7a9db367..42741fcf 100644 --- a/cfg/cfg_test.go +++ b/cfg/cfg_test.go @@ -1,10 +1,11 @@ package cfg_test import ( - "github.com/GeoNet/kit/cfg" "os" "strings" "testing" + + "github.com/GeoNet/kit/cfg" ) func TestPostgresEnv(t *testing.T) { diff --git a/datalogger_pb/datalogger.pb.go b/datalogger_pb/datalogger.pb.go index ec668c12..189b1c43 100644 --- a/datalogger_pb/datalogger.pb.go +++ b/datalogger_pb/datalogger.pb.go @@ -9,10 +9,11 @@ package datalogger_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -22,7 +23,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -//A structure containing all the devices listed in the network repo. +// A structure containing all the devices listed in the network repo. type Devices struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/fmp_pb/fmp.pb.go b/fmp_pb/fmp.pb.go index f2cd0fd4..7f192752 100644 --- a/fmp_pb/fmp.pb.go +++ b/fmp_pb/fmp.pb.go @@ -9,10 +9,11 @@ package fmp_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -22,7 +23,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -//A structure containing all the devices listed in the network repo. +// A structure containing all the devices listed in the network repo. type Devices struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/gloria_pb/gloria.pb.go b/gloria_pb/gloria.pb.go index 9432a9e6..4bf0b357 100644 --- a/gloria_pb/gloria.pb.go +++ b/gloria_pb/gloria.pb.go @@ -9,10 +9,11 @@ package gloria_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/haz_pb/haz.pb.go b/haz_pb/haz.pb.go index 39ea5a3e..1845347c 100644 --- a/haz_pb/haz.pb.go +++ b/haz_pb/haz.pb.go @@ -7,10 +7,11 @@ package haz_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/map180/bbox.go b/map180/bbox.go index 072cec1e..c914b3ff 100644 --- a/map180/bbox.go +++ b/map180/bbox.go @@ -16,9 +16,9 @@ type bbox struct { /* ValidBbox returns a nil error for a valid boundingBox. Valid options are one of: - * an empty string: "" - * a string definition of a bounding box using ',' separated - longitude latitude (float) on EPSG4327. This should be lower + - an empty string: "" + - a string definition of a bounding box using ',' separated + longitude latitude (float) on EPSG4327. This should be lower left and upper right corners. It may cross 180. Longitude can be -180 to 180 or 0 to 360. Latitude must be <= 85.0 && >= -85.0 Examples: "165,-48,179,-34" // New Zealand diff --git a/map180/map.go b/map180/map.go index 0ab23e1d..595f2e8b 100644 --- a/map180/map.go +++ b/map180/map.go @@ -9,11 +9,12 @@ import ( "context" "database/sql" "fmt" - "github.com/golang/groupcache" "log" "regexp" "strconv" "strings" + + "github.com/golang/groupcache" ) const ( @@ -76,7 +77,7 @@ for land and lake layers. region must be a valid Region. Example: - wm, err = map180.Init(db, map180.Region(`newzealand`), 256000000) + wm, err = map180.Init(db, map180.Region(`newzealand`), 256000000) */ func Init(d *sql.DB, region Region, cacheBytes int64) (*Map180, error) { w := &Map180{} @@ -331,38 +332,36 @@ func (w *Map180) Map(boundingBox string, width int, pts Points, insetBbox string /* MapRaw returns a Raw struct which can be used for drawing SVG maps e.g., - raw, err := wm.MapRaw(bbox, width) - b := bytes.Buffer - b.WriteString(``) - b.WriteString(fmt.Sprintf("", - raw.Width, raw.Height)) - b.WriteString(fmt.Sprintf("", raw.Width, raw.Height)) - b.WriteString(fmt.Sprintf("", raw.Land)) - b.WriteString(fmt.Sprintf("", raw.Lakes)) - b.WriteString("") + raw, err := wm.MapRaw(bbox, width) + b := bytes.Buffer + b.WriteString(``) + b.WriteString(fmt.Sprintf("", + raw.Width, raw.Height)) + b.WriteString(fmt.Sprintf("", raw.Width, raw.Height)) + b.WriteString(fmt.Sprintf("", raw.Land)) + b.WriteString(fmt.Sprintf("", raw.Lakes)) + b.WriteString("") The other properties can be used to scale and translate for drawing on the map e.g., - type point struct { - latitude, longitude float64 - x, y float64 - } - - // create pts []point with x,y, set to EPSG3857 and latitude longitude EPSG4326 - // range of pts ... - - switch raw.CrossesCentral && p.longitude > -180.0 && p.longitude < 0.0 { - case true: - p.x = (p.x + map180.Width3857 - raw.LLX) * raw.DX - p.y = (p.y - math.Abs(raw.YShift)) * raw.DX - case false: - p.x = (p.x - math.Abs(raw.XShift)) * raw.DX - p.y = (p.y - math.Abs(raw.YShift)) * raw.DX - } + type point struct { + latitude, longitude float64 + x, y float64 + } - // draw p on SVG. + // create pts []point with x,y, set to EPSG3857 and latitude longitude EPSG4326 + // range of pts ... + switch raw.CrossesCentral && p.longitude > -180.0 && p.longitude < 0.0 { + case true: + p.x = (p.x + map180.Width3857 - raw.LLX) * raw.DX + p.y = (p.y - math.Abs(raw.YShift)) * raw.DX + case false: + p.x = (p.x - math.Abs(raw.XShift)) * raw.DX + p.y = (p.y - math.Abs(raw.YShift)) * raw.DX + } + // draw p on SVG. */ func (w *Map180) MapRaw(boundingBox string, width int) (mr Raw, err error) { var b bbox diff --git a/map180/nzmap/nzmap.go b/map180/nzmap/nzmap.go index 7520a2e2..9b554c44 100644 --- a/map180/nzmap/nzmap.go +++ b/map180/nzmap/nzmap.go @@ -4,20 +4,19 @@ There are no external dependencies. Calling code can draw markers on the maps as required. The closing tag must also be added. - var b bytes.Buffer - var pts nzmap.Points + var b bytes.Buffer + var pts nzmap.Points - pts.Medium(b) + pts.Medium(b) - for _, p := range pts { - if p.Visible() { - b.WriteString(fmt.Sprintf("", - p.X(), p.Y())) + for _, p := range pts { + if p.Visible() { + b.WriteString(fmt.Sprintf("", + p.X(), p.Y())) + } } - } - - b.WriteString("") + b.WriteString("") */ package nzmap diff --git a/metrics/counters_test.go b/metrics/counters_test.go index e16ae7c3..fb38846b 100644 --- a/metrics/counters_test.go +++ b/metrics/counters_test.go @@ -1,10 +1,11 @@ package metrics_test import ( - "github.com/GeoNet/kit/metrics" "runtime" "strconv" "testing" + + "github.com/GeoNet/kit/metrics" ) func TestMsgCounters(t *testing.T) { diff --git a/metrics/timers_test.go b/metrics/timers_test.go index b74dbfa8..2fb05083 100644 --- a/metrics/timers_test.go +++ b/metrics/timers_test.go @@ -1,9 +1,10 @@ package metrics_test import ( - "github.com/GeoNet/kit/metrics" "testing" "time" + + "github.com/GeoNet/kit/metrics" ) func TestTimers(t *testing.T) { diff --git a/sc3ml/sc3ml_integration_test.go b/sc3ml/sc3ml_integration_test.go index 360601f8..57fedafb 100644 --- a/sc3ml/sc3ml_integration_test.go +++ b/sc3ml/sc3ml_integration_test.go @@ -16,7 +16,7 @@ import ( // under /work/seismcompml07-test and make sure basic quake facts // are not zero values. Run using: // -// go test -tags=integration +// go test -tags=integration func TestUnmarshalIntegration(t *testing.T) { var s sc3ml.Seiscomp var err error diff --git a/seis/dl/doc.go b/seis/dl/doc.go index 372839de..e81b3f6d 100644 --- a/seis/dl/doc.go +++ b/seis/dl/doc.go @@ -1,5 +1,4 @@ // The dl module has been writen as a lightweight replacement for the C libdali library. // It is aimed at clients that need to connect to a datalink server, either requesting inforamtion // or for uploading most likely miniseed records. -// package dl diff --git a/seis/ms/doc.go b/seis/ms/doc.go index f58ca47b..24f283b5 100644 --- a/seis/ms/doc.go +++ b/seis/ms/doc.go @@ -1,3 +1,2 @@ // The ms module has been writen as a lightweight replacement for some parts of the libmseed C library. -// package ms diff --git a/seis/ms/header.go b/seis/ms/header.go index d22163eb..55c3b193 100644 --- a/seis/ms/header.go +++ b/seis/ms/header.go @@ -3,6 +3,7 @@ package ms import ( "encoding/binary" "fmt" + //TODO: needs v 1.15 "hash/maphash" "strconv" "strings" diff --git a/seis/ms/record.go b/seis/ms/record.go index c4e8e5e7..e4fe13c4 100644 --- a/seis/ms/record.go +++ b/seis/ms/record.go @@ -44,7 +44,7 @@ type Record struct { } // NewMSRecord decodes and unpacks the record samples from a byte slice and returns a Record pointer, -//or an empty pointer and an error if it could not be decoded. +// or an empty pointer and an error if it could not be decoded. func NewRecord(buf []byte) (*Record, error) { var r Record diff --git a/seis/ms/steim.go b/seis/ms/steim.go index f0ee66a1..6abafc11 100644 --- a/seis/ms/steim.go +++ b/seis/ms/steim.go @@ -14,7 +14,7 @@ func getNibble(word []byte, index int) uint8 { return res } -//value must be 0, 1, 2 or 3, the nibble must not have been previously set +// value must be 0, 1, 2 or 3, the nibble must not have been previously set func writeNibble(word []byte, index int, value uint8) { b := word[index/4] i := index % 4 @@ -23,7 +23,7 @@ func writeNibble(word []byte, index int, value uint8) { } /* - Takes v: an integer where only the first numbits bits are used to represent the number and returns an int32 +Takes v: an integer where only the first numbits bits are used to represent the number and returns an int32 */ func uintVarToInt32(v uint32, numbits uint8) int32 { neg := (v & (0x1 << (numbits - 1))) != 0 //check positive/negative diff --git a/seis/sl/conn_test.go b/seis/sl/conn_test.go index 9c97bd78..833a321c 100644 --- a/seis/sl/conn_test.go +++ b/seis/sl/conn_test.go @@ -1,3 +1,4 @@ +//go:build link // +build link package sl diff --git a/seis/sl/doc.go b/seis/sl/doc.go index faac21ab..5c22be08 100644 --- a/seis/sl/doc.go +++ b/seis/sl/doc.go @@ -10,15 +10,14 @@ // // An example Seedlink application can be as simple as: // -// if err := sl.NewSLink().Collect(func(seq string, data []byte) (bool, error) { -// //... process miniseed data +// if err := sl.NewSLink().Collect(func(seq string, data []byte) (bool, error) { +// //... process miniseed data // -// return false, nil -// }); err != nil { -// log.Fatal(err) -// } +// return false, nil +// }); err != nil { +// log.Fatal(err) +// } // // A state mechanism is available for the initial connection, although it is the clients responsibility to // periodically maintain its content. -// package sl diff --git a/seis/sl/slink_test.go b/seis/sl/slink_test.go index e498eb61..ebda2f41 100644 --- a/seis/sl/slink_test.go +++ b/seis/sl/slink_test.go @@ -1,3 +1,4 @@ +//go:build link // +build link package sl diff --git a/weft/handlers_test.go b/weft/handlers_test.go index 2af9183f..c7daf156 100644 --- a/weft/handlers_test.go +++ b/weft/handlers_test.go @@ -3,10 +3,11 @@ package weft_test import ( "bytes" "errors" - "github.com/GeoNet/kit/weft" "net/http" "net/http/httptest" "testing" + + "github.com/GeoNet/kit/weft" ) func TestMakeHandler(t *testing.T) { diff --git a/weft/weft.go b/weft/weft.go index 4f27089c..71dd8195 100644 --- a/weft/weft.go +++ b/weft/weft.go @@ -73,9 +73,9 @@ func (s StatusError) Status() int { // Status returns the HTTP status code appropriate for err. // It returns: -// * http.StatusOk if err is nil -// * err.Code if err is a StatusErr and Code is set -// * otherwise http.StatusServiceUnavailable +// - http.StatusOk if err is nil +// - err.Code if err is a StatusErr and Code is set +// - otherwise http.StatusServiceUnavailable func Status(err error) int { if err == nil { return http.StatusOK diff --git a/weft/weft_test.go b/weft/weft_test.go index dcc93ef9..8b4dea98 100644 --- a/weft/weft_test.go +++ b/weft/weft_test.go @@ -2,12 +2,13 @@ package weft_test import ( "errors" - "github.com/GeoNet/kit/weft" "net/http" "runtime" "strconv" "strings" "testing" + + "github.com/GeoNet/kit/weft" ) func TestStatus(t *testing.T) { diff --git a/weft/wefttest/wefttest_test.go b/weft/wefttest/wefttest_test.go index f7ceead0..f3746be3 100644 --- a/weft/wefttest/wefttest_test.go +++ b/weft/wefttest/wefttest_test.go @@ -17,7 +17,7 @@ const ( maxAge86400 = "max-age=86400" ) -//expected csp header for normal responses +// expected csp header for normal responses var normalCspHeader = weft.ReturnDefaultCSP() // test server and handlers for running the tests @@ -138,7 +138,8 @@ func TestExtraParameter(t *testing.T) { // TestFuzzRoutes tests routes with fuzzed query parameters. // Fuzzing takes a while to run. Fuzz tests can be excluded during other testing with: -// go test -v -run 'Test[^Fuzz]' +// +// go test -v -run 'Test[^Fuzz]' func TestFuzzQuery(t *testing.T) { setup() defer teardown()