diff --git a/bitfinexwebsocket.go b/bitfinexwebsocket.go index 875689e2..62606d62 100644 --- a/bitfinexwebsocket.go +++ b/bitfinexwebsocket.go @@ -246,7 +246,7 @@ func (b *Bitfinex) WebsocketClient() { chanInfo, ok := b.WebsocketSubdChannels[chanID] if !ok { - log.Println("Unable to locate chanID: %d", chanID) + log.Printf("Unable to locate chanID: %d\n", chanID) } else { if len(chanData) == 2 { if reflect.TypeOf(chanData[1]).String() == "string" { diff --git a/bitstampwebsocket.go b/bitstampwebsocket.go index e85ae0ee..40660569 100644 --- a/bitstampwebsocket.go +++ b/bitstampwebsocket.go @@ -39,12 +39,12 @@ func (b *Bitstamp) PusherClient() { dataChannelTrade, err := pusherClient.Bind("data") if err != nil { - log.Printf("%s Websocket Bind error: ", b.GetName(), err) + log.Printf("%s Websocket Bind error: %s\n", b.GetName(), err) continue } tradeChannelTrade, err := pusherClient.Bind("trade") if err != nil { - log.Printf("%s Websocket Bind error: ", b.GetName(), err) + log.Printf("%s Websocket Bind error: %s\n", b.GetName(), err) continue } diff --git a/btccwebsocket.go b/btccwebsocket.go index 101b1566..e1d69f73 100644 --- a/btccwebsocket.go +++ b/btccwebsocket.go @@ -141,9 +141,9 @@ func (b *BTCC) WebsocketClient() { for b.Enabled && b.Websocket { err := socketio.ConnectToSocket(BTCC_SOCKETIO_ADDRESS, BTCCSocket) if err != nil { - log.Printf("%s Unable to connect to Websocket. Err: %s\n", err) + log.Printf("%s Unable to connect to Websocket. Err: %s\n", b.GetName(), err) continue } - log.Printf("%s Disconnected from Websocket.") + log.Printf("%s Disconnected from Websocket.\n", b.GetName()) } } diff --git a/common_test.go b/common_test.go index b9a21fe1..4f9781cc 100644 --- a/common_test.go +++ b/common_test.go @@ -124,7 +124,7 @@ func TestStringContains(t *testing.T) { expectedOutput := true actualResult := StringContains(originalInput, originalInputSubstring) if actualResult != expectedOutput { - t.Error(fmt.Sprintf("Test failed. Expected '%s'. Actual '%s'", expectedOutput, actualResult)) + t.Error(fmt.Sprintf("Test failed. Expected '%t'. Actual '%t'", expectedOutput, actualResult)) } } @@ -213,14 +213,14 @@ func TestExtractHost(t *testing.T) { expectedOutput := "localhost" actualResult := ExtractHost(address) if expectedOutput != actualResult { - t.Error(fmt.Sprintf("Test failed. Expected '%f'. Actual '%f'.", expectedOutput, actualResult)) + t.Error(fmt.Sprintf("Test failed. Expected '%s'. Actual '%s'.", expectedOutput, actualResult)) } address = "192.168.1.100:1337" expectedOutput = "192.168.1.100" actualResult = ExtractHost(address) if expectedOutput != actualResult { - t.Error(fmt.Sprintf("Test failed. Expected '%f'. Actual '%f'.", expectedOutput, actualResult)) + t.Error(fmt.Sprintf("Test failed. Expected '%s'. Actual '%s'.", expectedOutput, actualResult)) } } @@ -230,6 +230,6 @@ func TestExtractPort(t *testing.T) { expectedOutput := 1337 actualResult := ExtractPort(address) if expectedOutput != actualResult { - t.Error(fmt.Sprintf("Test failed. Expected '%f'. Actual '%f'.", expectedOutput, actualResult)) + t.Error(fmt.Sprintf("Test failed. Expected '%d'. Actual '%d'.", expectedOutput, actualResult)) } } diff --git a/huobiwebsocket.go b/huobiwebsocket.go index 75b4327f..e9e6c9ae 100644 --- a/huobiwebsocket.go +++ b/huobiwebsocket.go @@ -211,9 +211,9 @@ func (h *HUOBI) WebsocketClient() { for h.Enabled && h.Websocket { err := socketio.ConnectToSocket(HUOBI_SOCKETIO_ADDRESS, HuobiSocket) if err != nil { - log.Printf("%s Unable to connect to Websocket. Err: %s\n", err) + log.Printf("%s Unable to connect to Websocket. Err: %s\n", h.GetName(), err) continue } - log.Printf("%s Disconnected from Websocket.") + log.Printf("%s Disconnected from Websocket.\n", h.GetName()) } } diff --git a/okcoinwebsocket.go b/okcoinwebsocket.go index 90a23a8e..f9320379 100644 --- a/okcoinwebsocket.go +++ b/okcoinwebsocket.go @@ -482,7 +482,7 @@ func (o *OKCoin) WebsocketClient() { if success != "true" && success != nil { errorCodeStr, ok := errorcode.(string) if !ok { - log.Printf("%s Websocket: Unable to convert errorcode to string.\n", o.GetName) + log.Printf("%s Websocket: Unable to convert errorcode to string.\n", o.GetName()) log.Printf("%s Websocket: channel %s error code: %s.\n", o.GetName(), channelStr, errorcode) } else { log.Printf("%s Websocket: channel %s error: %s.\n", o.GetName(), channelStr, o.WebsocketErrors[errorCodeStr]) diff --git a/orders.go b/orders.go index 453d7e86..95a72803 100644 --- a/orders.go +++ b/orders.go @@ -1,4 +1,3 @@ - package main const ( @@ -9,16 +8,16 @@ const ( var Orders []*Order type Order struct { - OrderID int + OrderID int Exchange string - Type int - Amount float64 - Price float64 + Type int + Amount float64 + Price float64 } -func NewOrder(Exchange string, amount, price float64) (int) { +func NewOrder(Exchange string, amount, price float64) int { order := &Order{} - if (len(Orders) == 0) { + if len(Orders) == 0 { order.OrderID = 0 } else { order.OrderID = len(Orders) @@ -31,7 +30,7 @@ func NewOrder(Exchange string, amount, price float64) (int) { return order.OrderID } -func DeleteOrder(orderID int) (bool) { +func DeleteOrder(orderID int) bool { for i := range Orders { if Orders[i].OrderID == orderID { Orders = append(Orders[:i], Orders[i+1:]...) @@ -61,4 +60,4 @@ func GetOrderByOrderID(orderID int) (*Order, bool) { } } return nil, false -} \ No newline at end of file +} diff --git a/restfulLogger.go b/restfulLogger.go index a1f21d1b..3f002e31 100644 --- a/restfulLogger.go +++ b/restfulLogger.go @@ -1,23 +1,23 @@ package main import ( - "log" - "net/http" - "time" + "log" + "net/http" + "time" ) func Logger(inner http.Handler, name string) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - start := time.Now() + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() - inner.ServeHTTP(w, r) + inner.ServeHTTP(w, r) - log.Printf( - "%s\t%s\t%s\t%s", - r.Method, - r.RequestURI, - name, - time.Since(start), - ) - }) -} \ No newline at end of file + log.Printf( + "%s\t%s\t%s\t%s", + r.Method, + r.RequestURI, + name, + time.Since(start), + ) + }) +}