(Engine) Variety of engine updates (#390)

* drop common uuid v4 func and imported package as needed

* removed common functions regarding json marshal and unmarshal and used the json package directly. WRT unmarshal it was calling reflect and converted to string which is also checked in the JSON package so it was doing a double up, this will be a tiny gain as it was directly used in the requester package for all our outbound requests.

* add in string

* explicitly throw away return error value

* atleast return the error that websocket initialise returns

* return error when not connected

* fix comment

* Adds comments

* move package declarations

* drop append whenever we call supported

* remove unused import

* Change incorrect spelling

* fix tests

* fix go import issue
This commit is contained in:
Ryan O'Hara-Reid
2019-12-03 10:06:08 +11:00
committed by Adrian Gallagher
parent c27b8657e2
commit 0c5d75b22c
70 changed files with 393 additions and 462 deletions

View File

@@ -1,6 +1,7 @@
package currency
import (
"encoding/json"
"errors"
"fmt"
"strings"
@@ -11,7 +12,7 @@ import (
func (r Role) String() string {
switch r {
case Unset:
return UnsetRollString
return UnsetRoleString
case Fiat:
return FiatCurrencyString
case Cryptocurrency:
@@ -25,21 +26,21 @@ func (r Role) String() string {
}
}
// MarshalJSON conforms Roll to the marshaller interface
// MarshalJSON conforms Role to the marshaller interface
func (r Role) MarshalJSON() ([]byte, error) {
return common.JSONEncode(r.String())
return json.Marshal(r.String())
}
// UnmarshalJSON conforms Roll to the unmarshaller interface
// UnmarshalJSON conforms Role to the unmarshaller interface
func (r *Role) UnmarshalJSON(d []byte) error {
var incoming string
err := common.JSONDecode(d, &incoming)
err := json.Unmarshal(d, &incoming)
if err != nil {
return err
}
switch incoming {
case UnsetRollString:
case UnsetRoleString:
*r = Unset
case FiatCurrencyString:
*r = Fiat
@@ -400,7 +401,7 @@ func (c Code) Upper() Code {
// UnmarshalJSON comforms type to the umarshaler interface
func (c *Code) UnmarshalJSON(d []byte) error {
var newcode string
err := common.JSONDecode(d, &newcode)
err := json.Unmarshal(d, &newcode)
if err != nil {
return err
}
@@ -411,9 +412,9 @@ func (c *Code) UnmarshalJSON(d []byte) error {
// MarshalJSON conforms type to the marshaler interface
func (c Code) MarshalJSON() ([]byte, error) {
if c.Item == nil {
return common.JSONEncode("")
return json.Marshal("")
}
return common.JSONEncode(c.String())
return json.Marshal(c.String())
}
// IsEmpty returns true if the code is empty