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 all commits
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
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: false
language: go
go:
- "1.11"
- "1.12"
go_import_path: github.com/gonium/gosdm630
env:
global:
Expand All @@ -10,6 +10,10 @@ env:
- secure: "JObzZsqZNenjO9s/ptYSfPYRU/IMTuV0LlmkZwve9pGZN/GiCwNORQxniaTbVihqv4U8RdiyzHi9gjXkYuJY4FLOSf5e9oyoM8podPZuu1A5QIwOShaNAoAy8BB69I8RYN3fkMiGVFza5b+M2//6xoy3u98rQRYd/zO5BIOPTvQ07Ho2RQt84MG5Ge4b0WjZLVBK1JuJrtANvtLSjVdNKGvWD8/Nglnznrm/QlrkHX/O4aTwP+7Y1AsIobpuSU4xBINZsH2CCnEtYmf38dT1mJC+hQOhK4wD/QmxEw28/9LeYsECQ+WGdgM78UA76R0UpA2/RoKhhrGTsb5LLiiUWAp5XxM2Z2GNzm0L6F1Pg8C5ikQY7zR1qxAlvm5EcJdpo8e+EeSXGcnXSfEamSA/n+vsUel+pUyxT/0epEt1MfVrI7j7P+u7/HsVdfkiroc5m30YAG1xgEVUdddNC8VBWZwyINZLxPjvUVVyL5Z2vOIbYpucgx0jHkrdnNUhv84Ex66nf8oVPcJuJe23AtKltyjdqwWmVQqKgh7uwscHuykLbOeUgakWXggwdelGcUmRqgIiiF3lM4+At/vGLVHn37Qk8KC9DXav2wV9/yZVfBPXi2FjZqSOZnqkcKqMwDjbf1VI5rKhB5KcJh4dT9zn3xR7lR6mz2z+iCwdz3SU5hg="
- secure: "ILFSFTcZHfbuhimlSBGd+LLhVhaSRMG54U9ws43/ZbROS8zc9NRznhIbxQ2fqWIL1bvC1wLmlxa4HXbSOXWOXMqMZSpnc8zgvIkfqF3bQhBN2ArPkctz/xTVUspUz7VWqMhavvC+8mzwIjfTft+VkQADhTIdTG2pR+ak6z1qwyMPaovpef7qHZXbcpbu42r7gLvsfs/Tj7kQUG7GFTaTluzcV5L0ur2wnPMFg1y1jtuVjFHO6YH3SOeNMvvN6CarUNd5JoP9QrWdYD1z2LmCNadqQFJrHsE4ciz23eZtP2bWQnARGfLCbLj6pdFG4WTOgEKjmlXrsExczUlcLQh2datTkke1DcNX4FAIZbleq6SL/ra5EUKIgdnAvFYnRQExLnceB9gFZbg0knIeFPD21cp4tys0RP/NiiNi82VC2fDs8/tR1SgBK3PHseTD/uCbddLydOseI6BoYc17PbB85dhuIWtfGDm0jKY3a2GhUHRTNLpWdBHQnc4yh7fz3GV/JNmePu+SS7U2zJCVkTzPDdePO9tItwnN3b9yV5ZZc3v03/v9BerpQu953ahr9VNqlsgUkTa/YmLuzvv9lWmhRIpw7jMMAkcRg6c2MebcyEBaT1+AgTFe3WOvEAia1acWuCRb3b7r48xemkKu9DEmDFekVIcxmrPoIgVwXlhf42E="
- COMMIT=${TRAVIS_COMMIT::8}
before_install:
# Install linters and misspell
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.15.0
- golangci-lint --version
script:
- make
- make test
Expand Down
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