From d2f747933ff03d1506a522a6ec7c9c6ea649886a Mon Sep 17 00:00:00 2001 From: tidwall Date: Sat, 10 Jul 2021 03:59:27 -0700 Subject: [PATCH] clear linter messages --- internal/endpoint/pubsub.go | 31 ++++++++++--------------------- internal/server/fence.go | 9 ++++----- internal/server/server.go | 2 +- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/internal/endpoint/pubsub.go b/internal/endpoint/pubsub.go index 61a47b85..db6dac33 100644 --- a/internal/endpoint/pubsub.go +++ b/internal/endpoint/pubsub.go @@ -1,36 +1,25 @@ package endpoint import ( - "cloud.google.com/go/pubsub" "context" - "errors" "fmt" - "github.com/streadway/amqp" - "google.golang.org/api/option" "sync" "time" + + "cloud.google.com/go/pubsub" + "google.golang.org/api/option" ) const pubsubExpiresAfter = time.Second * 30 -var errMissingGoogleCredentials = errors.New("Could not find GCP credentials - no credential path was submitted and envar GOOGLE_APPLICATION_CREDENTIALS is not set") - // SQSConn is an endpoint connection type PubSubConn struct { - mu sync.Mutex - ep Endpoint - svc *pubsub.Client - topic *pubsub.Topic - channel *amqp.Channel - ex bool - t time.Time -} - -func (conn *PubSubConn) generatePubSubURL() string { - if conn.ep.SQS.PlainURL != "" { - return conn.ep.SQS.PlainURL - } - return "projects/" + conn.ep.PubSub.Project + "/topics/" + conn.ep.PubSub.Topic + mu sync.Mutex + ep Endpoint + svc *pubsub.Client + topic *pubsub.Topic + ex bool + t time.Time } func (conn *PubSubConn) close() { @@ -93,7 +82,7 @@ func (conn *PubSubConn) Expired() bool { conn.mu.Lock() defer conn.mu.Unlock() if !conn.ex { - if time.Now().Sub(conn.t) > pubsubExpiresAfter { + if time.Since(conn.t) > pubsubExpiresAfter { conn.ex = true conn.close() } diff --git a/internal/server/fence.go b/internal/server/fence.go index fcba97f9..2c3f71ec 100644 --- a/internal/server/fence.go +++ b/internal/server/fence.go @@ -335,8 +335,7 @@ func makemsg( } func fenceMatchObject(fence *liveFenceSwitches, obj geojson.Object) bool { - gobj, _ := obj.(geojson.Object) - if gobj == nil { + if obj == nil { return false } if fence.roam.on { @@ -346,11 +345,11 @@ func fenceMatchObject(fence *liveFenceSwitches, obj geojson.Object) bool { switch fence.cmd { case "nearby": // nearby is an INTERSECT on a Circle - return gobj.Intersects(fence.obj) + return obj.Intersects(fence.obj) case "within": - return gobj.Within(fence.obj) + return obj.Within(fence.obj) case "intersects": - return gobj.Intersects(fence.obj) + return obj.Intersects(fence.obj) } return false } diff --git a/internal/server/server.go b/internal/server/server.go index 2f531d78..11499a28 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -778,7 +778,7 @@ func (server *Server) handleInputCommand(client *Client, msg *Message) error { cmd := msg.Command() defer func() { - took := time.Now().Sub(start).Seconds() + took := time.Since(start).Seconds() cmdDurations.With(prometheus.Labels{"cmd": cmd}).Observe(took) }()