Skip to content

Commit

Permalink
Fixes for gometalinter
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiet480 committed Sep 3, 2018
1 parent c5bd76b commit ae986ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion .gometalinter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"Enable": [
"deadcode",
"errcheck",
"gochecknoglobals",
"gochecknoinits",
"goconst",
"gofmt",
Expand Down
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import (
)

var (
namespace = "telly"
log = logrus.New()
opts = config{}
log = logrus.New()
opts = config{}

exposedChannels = prometheus.NewGauge(
prometheus.GaugeOpts{
Expand Down
18 changes: 8 additions & 10 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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(
Expand All @@ -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
}

0 comments on commit ae986ec

Please sign in to comment.