mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
(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:
committed by
Adrian Gallagher
parent
c27b8657e2
commit
0c5d75b22c
@@ -12,13 +12,11 @@ import (
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
log "github.com/thrasher-corp/gocryptotrader/logger"
|
||||
)
|
||||
|
||||
@@ -43,11 +41,6 @@ const (
|
||||
WeiPerEther = 1000000000000000000
|
||||
)
|
||||
|
||||
// GetV4UUID returns a RFC 4122 UUID based on random numbers
|
||||
func GetV4UUID() (uuid.UUID, error) {
|
||||
return uuid.NewV4()
|
||||
}
|
||||
|
||||
func initialiseHTTPClient() {
|
||||
// If the HTTPClient isn't set, start a new client with a default timeout of 15 seconds
|
||||
if HTTPClient == nil {
|
||||
@@ -227,7 +220,7 @@ func SendHTTPGetRequest(urlPath string, jsonDecode, isVerbose bool, result inter
|
||||
defer res.Body.Close()
|
||||
|
||||
if jsonDecode {
|
||||
err := JSONDecode(contents, result)
|
||||
err := json.Unmarshal(contents, result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -236,19 +229,6 @@ func SendHTTPGetRequest(urlPath string, jsonDecode, isVerbose bool, result inter
|
||||
return nil
|
||||
}
|
||||
|
||||
// JSONEncode encodes structure data into JSON
|
||||
func JSONEncode(v interface{}) ([]byte, error) {
|
||||
return json.Marshal(v)
|
||||
}
|
||||
|
||||
// JSONDecode decodes JSON data into a structure
|
||||
func JSONDecode(data []byte, to interface{}) error {
|
||||
if !strings.Contains(reflect.ValueOf(to).Type().String(), "*") {
|
||||
return errors.New("json decode error - memory address not supplied")
|
||||
}
|
||||
return json.Unmarshal(data, to)
|
||||
}
|
||||
|
||||
// EncodeURLValues concatenates url values onto a url string and returns a
|
||||
// string
|
||||
func EncodeURLValues(urlPath string, values url.Values) string {
|
||||
|
||||
Reference in New Issue
Block a user