Skip to content

Commit 37cf997

Browse files
committed
apply suggestions from code review ✨
1 parent 5db1975 commit 37cf997

6 files changed

+12
-25
lines changed

bufferflow.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
package main
22

3-
// availableBufferAlgorithms = {"default", "timed", "timedraw", "timedbinary"}
4-
5-
type BufferMsg struct {
6-
Cmd string
7-
Port string
8-
TriggeringResponse string
9-
//Desc string
10-
//Desc string
11-
}
12-
133
type Bufferflow interface {
144
Init()
155
BlockUntilReady(cmd string, id string) (bool, bool) // implement this method

bufferflow_default.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import (
88

99
type BufferflowDefault struct {
1010
port string
11-
output chan []byte
11+
output chan<- []byte
1212
input chan string
1313
done chan bool
1414
}
1515

16-
func NewBufferflowDefault(port string, output chan []byte) *BufferflowDefault {
16+
func NewBufferflowDefault(port string, output chan<- []byte) *BufferflowDefault {
1717
return &BufferflowDefault{
1818
port: port,
1919
output: output,

bufferflow_timed.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99

1010
type BufferflowTimed struct {
1111
port string
12-
output chan []byte
12+
output chan<- []byte
1313
input chan string
1414
done chan bool
1515
ticker *time.Ticker
1616
sPort string
1717
bufferedOutput string
1818
}
1919

20-
func NewBufferflowTimed(port string, output chan []byte) *BufferflowTimed {
20+
func NewBufferflowTimed(port string, output chan<- []byte) *BufferflowTimed {
2121
return &BufferflowTimed{
2222
port: port,
2323
output: output,

bufferflow_timedbinary.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99

1010
type BufferflowTimedBinary struct {
1111
port string
12-
output chan []byte
12+
output chan<- []byte
1313
input chan []byte
1414
done chan bool
1515
ticker *time.Ticker
1616
bufferedOutputBinary []byte
1717
sPortBinary string
1818
}
1919

20-
func NewBufferflowTimedBinary(port string, output chan []byte) *BufferflowTimedBinary {
20+
func NewBufferflowTimedBinary(port string, output chan<- []byte) *BufferflowTimedBinary {
2121
return &BufferflowTimedBinary{
2222
port: port,
2323
output: output,
@@ -68,10 +68,6 @@ func (b *BufferflowTimedBinary) OnIncomingData(data string) {
6868
b.input <- []byte(data)
6969
}
7070

71-
func (b *BufferflowTimedBinary) IsBufferGloballySendingBackIncomingData() bool {
72-
return true
73-
}
74-
7571
func (b *BufferflowTimedBinary) Close() {
7672
b.ticker.Stop()
7773
b.done <- true

bufferflow_timedraw.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99

1010
type BufferflowTimedRaw struct {
1111
port string
12-
output chan []byte
12+
output chan<- []byte
1313
input chan string
1414
done chan bool
1515
ticker *time.Ticker
1616
bufferedOutputRaw []byte
1717
sPortRaw string
1818
}
1919

20-
func NewBufferflowTimedRaw(port string, output chan []byte) *BufferflowTimedRaw {
20+
func NewBufferflowTimedRaw(port string, output chan<- []byte) *BufferflowTimedRaw {
2121
return &BufferflowTimedRaw{
2222
port: port,
2323
output: output,

hub.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"io"
67
"os"
78
"runtime"
@@ -84,10 +85,10 @@ func (h *hub) run() {
8485
case c := <-h.register:
8586
h.connections[c] = true
8687
// send supported commands
87-
c.send <- []byte("{\"Version\" : \"" + version + "\"} ")
88+
c.send <- []byte(fmt.Sprintf(`{"Version" : "%s"} `, version))
8889
c.send <- []byte(commands)
89-
c.send <- []byte("{\"Hostname\" : \"" + *hostname + "\"} ")
90-
c.send <- []byte("{\"OS\" : \"" + runtime.GOOS + "\"} ")
90+
c.send <- []byte(fmt.Sprintf(`{"Hostname" : "%s"} `, *hostname))
91+
c.send <- []byte(fmt.Sprintf(`{"OS" : "%s"} `, runtime.GOOS))
9192
case c := <-h.unregister:
9293
h.unregisterConnection(c)
9394
case m := <-h.broadcast:

0 commit comments

Comments
 (0)