From ae986ec1abdda7beabb388051a09d9f1c867606d Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Sun, 2 Sep 2018 19:21:33 -0700 Subject: [PATCH] Fixes for gometalinter --- .gometalinter.json | 1 - main.go | 5 ++--- routes.go | 18 ++++++++---------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.gometalinter.json b/.gometalinter.json index 0f123cd..8addeeb 100644 --- a/.gometalinter.json +++ b/.gometalinter.json @@ -2,7 +2,6 @@ "Enable": [ "deadcode", "errcheck", - "gochecknoglobals", "gochecknoinits", "goconst", "gofmt", diff --git a/main.go b/main.go index 4aa8f17..896263f 100644 --- a/main.go +++ b/main.go @@ -17,9 +17,8 @@ import ( ) var ( - namespace = "telly" - log = logrus.New() - opts = config{} + log = logrus.New() + opts = config{} exposedChannels = prometheus.NewGauge( prometheus.GaugeOpts{ diff --git a/routes.go b/routes.go index f1d1139..854e155 100644 --- a/routes.go +++ b/routes.go @@ -49,7 +49,7 @@ func serve(opts config) { if opts.SSDP { log.Debugln("advertising telly service on network via UPNP/SSDP") - if _, ssdpErr := setupSSDP(opts.BaseAddress.String(), opts.FriendlyName, opts.DeviceUUID); ssdpErr != nil { + if ssdpErr := setupSSDP(opts.BaseAddress.String(), opts.FriendlyName, opts.DeviceUUID); ssdpErr != nil { log.WithError(ssdpErr).Errorln("telly cannot advertise over ssdp") } } @@ -93,7 +93,7 @@ func stream(c *gin.Context) { decodedStreamURI, decodeErr := base64.StdEncoding.DecodeString(channelID) if decodeErr != nil { log.WithError(decodeErr).Errorf("Invalid base64: %s", channelID) - c.AbortWithError(http.StatusBadRequest, decodeErr) + c.AbortWithError(http.StatusBadRequest, decodeErr) // nolint: errcheck return } @@ -133,7 +133,7 @@ func ginrus() gin.HandlerFunc { } } -func setupSSDP(baseAddress, deviceName, deviceUUID string) (*ssdp.Advertiser, error) { +func setupSSDP(baseAddress, deviceName, deviceUUID string) error { log.Debugf("Advertising telly as %s (%s)", deviceName, deviceUUID) adv, err := ssdp.Advertise( @@ -144,21 +144,19 @@ func setupSSDP(baseAddress, deviceName, deviceUUID string) (*ssdp.Advertiser, er 1800) if err != nil { - return nil, err + return err } go func(advertiser *ssdp.Advertiser) { aliveTick := time.Tick(15 * time.Second) for { - select { - case <-aliveTick: - if err := advertiser.Alive(); err != nil { - log.WithError(err).Panicln("error when sending ssdp heartbeat") - } + <-aliveTick + if err := advertiser.Alive(); err != nil { + log.WithError(err).Panicln("error when sending ssdp heartbeat") } } }(adv) - return adv, nil + return nil }