Skip to content
This repository has been archived by the owner on Jun 25, 2019. It is now read-only.

Fix linting errors #135

Merged
merged 2 commits into from
May 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix linting errors
  • Loading branch information
andig committed Apr 21, 2019
commit 8b54929d1ea36533d57b89e496186045cd0f6dd4
10 changes: 5 additions & 5 deletions cmd/sdm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@ func main() {
waitForSignal(os.Interrupt, os.Kill)
log.Println("Received signal - stopping")
cancelScheduler() // cancel scheduler
select { // wait for Run methods attached to tee to finish
case <-tee.Done():
log.Println("Stopped")
os.Exit(0)
}

// wait for Run methods attached to tee to finish
<-tee.Done()
log.Println("Stopped")
os.Exit(0)
}()

Run_httpd(
Expand Down
25 changes: 9 additions & 16 deletions homie.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ func (m *HomieRunner) publishProperties(subtopic string, meter *Meter, qe *Modbu
Operation: op,
}
if b, err := qe.Query(snip); err == nil {
for _, snip := range qe.Transform(snip, b) {
snips = append(snips, snip)
}
snips = append(snips, qe.Transform(snip, b)...)
}
}

Expand Down Expand Up @@ -183,9 +181,6 @@ func (m *HomieRunner) unpublish(subtopic string) {

topic := msg.Topic()
token := m.client.Publish(topic, byte(m.mqttQos), true, []byte{})
if m.verbose {
// log.Printf("MQTT: unpublish %s", topic)
}

mux.Lock()
defer mux.Unlock()
Expand All @@ -194,17 +189,15 @@ func (m *HomieRunner) unpublish(subtopic string) {
mux.Unlock()

// wait for timeout according to specification
select {
case <-time.After(timeout):
mux.Lock()
defer mux.Unlock()
<-time.After(timeout)
mux.Lock()
defer mux.Unlock()

// stop listening
m.client.Unsubscribe(topic)
// stop listening
m.client.Unsubscribe(topic)

// wait for tokens
for _, token := range tokens {
m.WaitForToken(token)
}
// wait for tokens
for _, token := range tokens {
m.WaitForToken(token)
}
}
5 changes: 1 addition & 4 deletions measurementcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ func (mc *MeasurementCache) Run(in QuerySnipChannel) {
if meter, ok := mc.meters[devid]; ok {
// add the snip to the cache
meter.AddSnip(snip)
if mc.verbose {
// log.Printf("%s\r\n", meter.Current.String())
}
} else {
log.Fatalf("Snip for unknown meter received - this should not happen (%v).", snip)
}
Expand All @@ -75,7 +72,7 @@ func (mc *MeasurementCache) Purge(deviceId byte) error {

func (mc *MeasurementCache) GetSortedIDs() []byte {
var keys ByteSlice
for k, _ := range mc.meters {
for k := range mc.meters {
keys = append(keys, k)
}
sort.Sort(keys)
Expand Down
2 changes: 1 addition & 1 deletion meters/impl/inepro.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (p *IneproProducer) Probe() Operation {
}

func (p *IneproProducer) Produce() (res []Operation) {
for op, _ := range p.Opcodes {
for op := range p.Opcodes {
res = append(res, p.snip(op))
}

Expand Down
6 changes: 2 additions & 4 deletions scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ func (q *MeterScheduler) Run(ctx context.Context, rate time.Duration) {
go q.handleControlSnips()

// wait for cancel
select {
case <-ctx.Done():
done <- true
}
<-ctx.Done()
done <- true
}
10 changes: 4 additions & 6 deletions socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ func (c *Client) writePump() {
c.conn.Close()
}()
for {
select {
case msg := <-c.send:
c.conn.SetWriteDeadline(time.Now().Add(socketWriteWait))
if err := c.conn.WriteMessage(websocket.TextMessage, msg); err != nil {
return
}
msg := <-c.send
c.conn.SetWriteDeadline(time.Now().Add(socketWriteWait))
if err := c.conn.WriteMessage(websocket.TextMessage, msg); err != nil {
return
}
}
}
Expand Down