From 8333e5c56a893ac8ebd5249d9aeb0bb9fc055894 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Tue, 20 Aug 2024 11:37:52 +1000 Subject: [PATCH 01/34] tag optional sonic and allow full library conversion --- backtester/btcli/main.go | 2 +- backtester/config/backtesterconfig.go | 2 +- backtester/config/batcktesterconfig_test.go | 2 +- backtester/config/strategyconfig.go | 2 +- backtester/config/strategyconfig_test.go | 2 +- .../config/strategyconfigbuilder/main.go | 2 +- .../eventhandlers/statistics/statistics.go | 2 +- backtester/main.go | 2 +- cmd/apichecker/apicheck.go | 2 +- cmd/apichecker/apicheck_test.go | 2 +- cmd/config/config.go | 2 +- cmd/config_builder/builder.go | 2 +- cmd/documentation/documentation.go | 2 +- cmd/exchange_wrapper_issues/main.go | 2 +- cmd/exchange_wrapper_issues/types.go | 3 +-- cmd/gctcli/main.go | 2 +- cmd/gen_sqlboiler_config/main.go | 2 +- cmd/websocket_client/main.go | 2 +- common/convert/convert.go | 2 +- common/convert/convert_test.go | 2 +- communications/slack/slack.go | 2 +- communications/slack/slack_test.go | 2 +- communications/telegram/telegram.go | 2 +- config/config.go | 2 +- currency/code.go | 3 ++- currency/code_test.go | 3 ++- currency/currencies.go | 3 ++- currency/currencies_test.go | 2 +- currency/manager.go | 2 +- currency/manager_test.go | 2 +- currency/pair_methods.go | 3 ++- currency/pair_test.go | 2 +- currency/pairs.go | 3 ++- currency/pairs_test.go | 2 +- currency/storage.go | 2 +- encoding/json/common.go | 8 ++++++++ encoding/json/json.go | 16 ++++++++++++++++ encoding/json/sonic.go | 16 ++++++++++++++++ engine/apiserver.go | 2 +- engine/apiserver_test.go | 2 +- engine/rpcserver.go | 2 +- engine/rpcserver_test.go | 2 +- exchanges/alphapoint/alphapoint.go | 2 +- exchanges/alphapoint/alphapoint_test.go | 2 +- exchanges/alphapoint/alphapoint_websocket.go | 2 +- exchanges/asset/asset.go | 3 ++- exchanges/asset/asset_test.go | 2 +- exchanges/binance/binance.go | 2 +- exchanges/binance/binance_cfutures.go | 2 +- exchanges/binance/binance_test.go | 2 +- exchanges/binance/binance_ufutures.go | 2 +- exchanges/binance/binance_websocket.go | 2 +- exchanges/binance/cfutures_types_test.go | 3 ++- exchanges/binance/type_convert.go | 3 ++- exchanges/binanceus/binanceus.go | 2 +- exchanges/binanceus/binanceus_test.go | 2 +- exchanges/binanceus/binanceus_websocket.go | 2 +- exchanges/binanceus/type_convert.go | 3 ++- exchanges/bitfinex/bitfinex.go | 2 +- exchanges/bitfinex/bitfinex_websocket.go | 2 +- exchanges/bithumb/bithumb.go | 2 +- exchanges/bithumb/bithumb_types.go | 3 +-- exchanges/bithumb/bithumb_websocket.go | 2 +- exchanges/bithumb/bithumb_websocket_types.go | 2 +- exchanges/bithumb/convert.go | 3 ++- exchanges/bithumb/convert_test.go | 3 ++- exchanges/bitmex/bitmex.go | 2 +- exchanges/bitmex/bitmex_websocket.go | 2 +- exchanges/bitstamp/bitstamp.go | 2 +- exchanges/bitstamp/bitstamp_type_convert.go | 2 +- exchanges/bitstamp/bitstamp_websocket.go | 2 +- exchanges/btcmarkets/btcmarkets.go | 2 +- exchanges/btcmarkets/btcmarkets_websocket.go | 2 +- exchanges/btse/btse.go | 2 +- exchanges/btse/btse_websocket.go | 2 +- exchanges/bybit/bybit.go | 2 +- exchanges/bybit/bybit_convert.go | 2 +- exchanges/bybit/bybit_options_websocket.go | 2 +- exchanges/bybit/bybit_test.go | 2 +- exchanges/bybit/bybit_types.go | 2 +- exchanges/bybit/bybit_websocket.go | 2 +- exchanges/coinbasepro/coinbasepro.go | 2 +- exchanges/coinbasepro/coinbasepro_websocket.go | 2 +- exchanges/coinut/coinut.go | 2 +- exchanges/coinut/coinut_websocket.go | 2 +- exchanges/collateral/collateral.go | 3 ++- exchanges/collateral/collateral_test.go | 3 ++- exchanges/deribit/deribit.go | 2 +- exchanges/deribit/deribit_test.go | 2 +- exchanges/deribit/deribit_types.go | 2 +- exchanges/deribit/deribit_websocket.go | 2 +- exchanges/deribit/deribit_websocket_eps.go | 2 +- exchanges/gateio/gateio.go | 2 +- exchanges/gateio/gateio_convert.go | 3 ++- exchanges/gateio/gateio_test.go | 2 +- exchanges/gateio/gateio_types.go | 2 +- exchanges/gateio/gateio_websocket.go | 2 +- exchanges/gateio/gateio_ws_delivery_futures.go | 2 +- exchanges/gateio/gateio_ws_futures.go | 2 +- exchanges/gateio/gateio_ws_option.go | 2 +- exchanges/gemini/gemini.go | 2 +- exchanges/gemini/gemini_websocket.go | 2 +- exchanges/hitbtc/hitbtc_websocket.go | 2 +- exchanges/huobi/huobi.go | 2 +- exchanges/huobi/huobi_futures.go | 2 +- exchanges/huobi/huobi_websocket.go | 2 +- exchanges/kraken/kraken.go | 2 +- exchanges/kraken/kraken_futures.go | 2 +- exchanges/kraken/kraken_test.go | 2 +- exchanges/kraken/kraken_types.go | 2 +- exchanges/kraken/kraken_websocket.go | 2 +- exchanges/kucoin/kucoin.go | 2 +- exchanges/kucoin/kucoin_convert.go | 3 ++- exchanges/kucoin/kucoin_test.go | 2 +- exchanges/kucoin/kucoin_types.go | 2 +- exchanges/kucoin/kucoin_websocket.go | 2 +- exchanges/lbank/lbank.go | 2 +- exchanges/lbank/lbank_types.go | 2 +- exchanges/margin/margin.go | 3 ++- exchanges/margin/margin_test.go | 3 ++- exchanges/mock/common.go | 3 ++- exchanges/mock/common_test.go | 3 ++- exchanges/mock/recording.go | 2 +- exchanges/mock/recording_test.go | 3 ++- exchanges/mock/server.go | 2 +- exchanges/mock/server_test.go | 2 +- exchanges/okcoin/okcoin.go | 2 +- exchanges/okcoin/okcoin_convert.go | 3 ++- exchanges/okcoin/okcoin_websocket.go | 2 +- exchanges/okcoin/okcoin_ws_trade.go | 2 +- exchanges/okx/okx.go | 2 +- exchanges/okx/okx_test.go | 2 +- exchanges/okx/okx_type_convert.go | 2 +- exchanges/okx/okx_types.go | 2 +- exchanges/okx/okx_websocket.go | 2 +- exchanges/order/order_test.go | 2 +- exchanges/order/orders.go | 2 +- exchanges/poloniex/poloniex.go | 2 +- exchanges/poloniex/poloniex_types.go | 2 +- exchanges/poloniex/poloniex_websocket.go | 2 +- exchanges/request/request.go | 2 +- exchanges/stream/websocket_connection.go | 2 +- exchanges/stream/websocket_test.go | 2 +- exchanges/subscription/subscription_test.go | 2 +- go.mod | 7 +++++++ go.sum | 18 ++++++++++++++++++ log/logger_multiwriter.go | 3 ++- log/logger_test.go | 2 +- portfolio/portfolio.go | 2 +- 149 files changed, 231 insertions(+), 146 deletions(-) create mode 100644 encoding/json/common.go create mode 100644 encoding/json/json.go create mode 100644 encoding/json/sonic.go diff --git a/backtester/btcli/main.go b/backtester/btcli/main.go index e3c1049b64c..f4145e6ef33 100644 --- a/backtester/btcli/main.go +++ b/backtester/btcli/main.go @@ -2,7 +2,6 @@ package main import ( "context" - "encoding/json" "fmt" "log" "os" @@ -13,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/core" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/gctrpc/auth" "github.com/thrasher-corp/gocryptotrader/signaler" "github.com/urfave/cli/v2" diff --git a/backtester/config/backtesterconfig.go b/backtester/config/backtesterconfig.go index 9b13bd1b320..f38a2d1726c 100644 --- a/backtester/config/backtesterconfig.go +++ b/backtester/config/backtesterconfig.go @@ -1,7 +1,6 @@ package config import ( - "encoding/json" "fmt" "os" "path/filepath" @@ -9,6 +8,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/backtester/common" "github.com/thrasher-corp/gocryptotrader/common/file" gctconfig "github.com/thrasher-corp/gocryptotrader/config" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // ReadBacktesterConfigFromPath will take a config from a path diff --git a/backtester/config/batcktesterconfig_test.go b/backtester/config/batcktesterconfig_test.go index a3834a0fc97..d88872d613e 100644 --- a/backtester/config/batcktesterconfig_test.go +++ b/backtester/config/batcktesterconfig_test.go @@ -1,13 +1,13 @@ package config import ( - "encoding/json" "errors" "path/filepath" "testing" "github.com/thrasher-corp/gocryptotrader/backtester/common" "github.com/thrasher-corp/gocryptotrader/common/file" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestLoadBacktesterConfig(t *testing.T) { diff --git a/backtester/config/strategyconfig.go b/backtester/config/strategyconfig.go index 2bb195aa08e..13ad77fdbbb 100644 --- a/backtester/config/strategyconfig.go +++ b/backtester/config/strategyconfig.go @@ -1,7 +1,6 @@ package config import ( - "encoding/json" "fmt" "os" "strings" @@ -13,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/backtester/eventhandlers/strategies/base" gctcommon "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/file" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/log" ) diff --git a/backtester/config/strategyconfig_test.go b/backtester/config/strategyconfig_test.go index 15353dc790a..9fbf77173b5 100644 --- a/backtester/config/strategyconfig_test.go +++ b/backtester/config/strategyconfig_test.go @@ -1,7 +1,6 @@ package config import ( - "encoding/json" "errors" "os" "path/filepath" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/currency" "github.com/thrasher-corp/gocryptotrader/database" "github.com/thrasher-corp/gocryptotrader/database/drivers" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" diff --git a/backtester/config/strategyconfigbuilder/main.go b/backtester/config/strategyconfigbuilder/main.go index 15d82ba54aa..a7ff152c7cd 100644 --- a/backtester/config/strategyconfigbuilder/main.go +++ b/backtester/config/strategyconfigbuilder/main.go @@ -2,7 +2,6 @@ package main import ( "bufio" - "encoding/json" "errors" "fmt" "log" @@ -23,6 +22,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/database" dbPSQL "github.com/thrasher-corp/gocryptotrader/database/drivers/postgres" dbsqlite3 "github.com/thrasher-corp/gocryptotrader/database/drivers/sqlite3" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" gctkline "github.com/thrasher-corp/gocryptotrader/exchanges/kline" ) diff --git a/backtester/eventhandlers/statistics/statistics.go b/backtester/eventhandlers/statistics/statistics.go index 9319bdb0bf8..f47d5434c56 100644 --- a/backtester/eventhandlers/statistics/statistics.go +++ b/backtester/eventhandlers/statistics/statistics.go @@ -1,7 +1,6 @@ package statistics import ( - "encoding/json" "fmt" "time" @@ -17,6 +16,7 @@ import ( gctcommon "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/key" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/log" ) diff --git a/backtester/main.go b/backtester/main.go index 1cca7abe493..eca2fa8155a 100644 --- a/backtester/main.go +++ b/backtester/main.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "flag" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/backtester/plugins/strategies" "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/common/file" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/engine" "github.com/thrasher-corp/gocryptotrader/log" "github.com/thrasher-corp/gocryptotrader/signaler" diff --git a/cmd/apichecker/apicheck.go b/cmd/apichecker/apicheck.go index 38417156c86..a40f3bef4f4 100644 --- a/cmd/apichecker/apicheck.go +++ b/cmd/apichecker/apicheck.go @@ -2,7 +2,6 @@ package main import ( "context" - "encoding/json" "errors" "flag" "fmt" @@ -18,6 +17,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" gctfile "github.com/thrasher-corp/gocryptotrader/common/file" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/request" "github.com/thrasher-corp/gocryptotrader/log" diff --git a/cmd/apichecker/apicheck_test.go b/cmd/apichecker/apicheck_test.go index dacf40aedc1..b04bfc854c2 100644 --- a/cmd/apichecker/apicheck_test.go +++ b/cmd/apichecker/apicheck_test.go @@ -1,12 +1,12 @@ package main import ( - "encoding/json" "os" "reflect" "testing" gctfile "github.com/thrasher-corp/gocryptotrader/common/file" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/log" ) diff --git a/cmd/config/config.go b/cmd/config/config.go index b7a90cb8e4b..d3e9e6ab6a1 100644 --- a/cmd/config/config.go +++ b/cmd/config/config.go @@ -1,13 +1,13 @@ package main import ( - "encoding/json" "flag" "log" "os" "github.com/thrasher-corp/gocryptotrader/common/file" "github.com/thrasher-corp/gocryptotrader/config" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // EncryptOrDecrypt returns a string from a boolean diff --git a/cmd/config_builder/builder.go b/cmd/config_builder/builder.go index 31792b0d0c1..ecf038e96e3 100644 --- a/cmd/config_builder/builder.go +++ b/cmd/config_builder/builder.go @@ -2,11 +2,11 @@ package main import ( "context" - "encoding/json" "log" "sync" "github.com/thrasher-corp/gocryptotrader/config" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/engine" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" ) diff --git a/cmd/documentation/documentation.go b/cmd/documentation/documentation.go index 9416108ec98..8e3be089812 100644 --- a/cmd/documentation/documentation.go +++ b/cmd/documentation/documentation.go @@ -2,7 +2,6 @@ package main import ( "context" - "encoding/json" "errors" "flag" "fmt" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/file" "github.com/thrasher-corp/gocryptotrader/core" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "golang.org/x/text/cases" "golang.org/x/text/language" ) diff --git a/cmd/exchange_wrapper_issues/main.go b/cmd/exchange_wrapper_issues/main.go index 0e1aa3aa350..c545d98d64a 100644 --- a/cmd/exchange_wrapper_issues/main.go +++ b/cmd/exchange_wrapper_issues/main.go @@ -2,7 +2,6 @@ package main import ( "context" - "encoding/json" "errors" "flag" "fmt" @@ -19,6 +18,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/file" "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/engine" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/account" diff --git a/cmd/exchange_wrapper_issues/types.go b/cmd/exchange_wrapper_issues/types.go index 156a1fa3868..66a5005081f 100644 --- a/cmd/exchange_wrapper_issues/types.go +++ b/cmd/exchange_wrapper_issues/types.go @@ -1,10 +1,9 @@ package main import ( - "encoding/json" - "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) diff --git a/cmd/gctcli/main.go b/cmd/gctcli/main.go index 682e8750802..7c170ceade4 100644 --- a/cmd/gctcli/main.go +++ b/cmd/gctcli/main.go @@ -2,7 +2,6 @@ package main import ( "context" - "encoding/json" "fmt" "log" "os" @@ -12,6 +11,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/core" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/gctrpc/auth" "github.com/thrasher-corp/gocryptotrader/signaler" diff --git a/cmd/gen_sqlboiler_config/main.go b/cmd/gen_sqlboiler_config/main.go index dbec363272a..3a1b05c80b5 100644 --- a/cmd/gen_sqlboiler_config/main.go +++ b/cmd/gen_sqlboiler_config/main.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "flag" "fmt" "os" @@ -12,6 +11,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/database" "github.com/thrasher-corp/gocryptotrader/database/repository" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) var ( diff --git a/cmd/websocket_client/main.go b/cmd/websocket_client/main.go index 769ff35bf2c..24929bf072c 100644 --- a/cmd/websocket_client/main.go +++ b/cmd/websocket_client/main.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "errors" "fmt" "log" @@ -13,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/config" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) diff --git a/common/convert/convert.go b/common/convert/convert.go index ccb8294bb27..4598c56457c 100644 --- a/common/convert/convert.go +++ b/common/convert/convert.go @@ -1,7 +1,6 @@ package convert import ( - "encoding/json" "fmt" "math" "strconv" @@ -9,6 +8,7 @@ import ( "time" "github.com/shopspring/decimal" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // FloatFromString format diff --git a/common/convert/convert_test.go b/common/convert/convert_test.go index c42579216bc..cab6ef43134 100644 --- a/common/convert/convert_test.go +++ b/common/convert/convert_test.go @@ -1,12 +1,12 @@ package convert import ( - "encoding/json" "strings" "testing" "time" "github.com/shopspring/decimal" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestFloatFromString(t *testing.T) { diff --git a/communications/slack/slack.go b/communications/slack/slack.go index 193f4c1a4ad..1bd795f15fb 100644 --- a/communications/slack/slack.go +++ b/communications/slack/slack.go @@ -5,7 +5,6 @@ package slack import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -16,6 +15,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/communications/base" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/log" ) diff --git a/communications/slack/slack_test.go b/communications/slack/slack_test.go index f7f307a5cc4..6bc00da6c05 100644 --- a/communications/slack/slack_test.go +++ b/communications/slack/slack_test.go @@ -1,11 +1,11 @@ package slack import ( - "encoding/json" "testing" "github.com/thrasher-corp/gocryptotrader/communications/base" "github.com/thrasher-corp/gocryptotrader/config" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) type group struct { diff --git a/communications/telegram/telegram.go b/communications/telegram/telegram.go index bb826b94eca..1ddee6dd09f 100644 --- a/communications/telegram/telegram.go +++ b/communications/telegram/telegram.go @@ -6,7 +6,6 @@ package telegram import ( "bytes" "context" - "encoding/json" "errors" "fmt" "net/http" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/communications/base" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/log" ) diff --git a/config/config.go b/config/config.go index 9d9448b6180..a7f9d60218b 100644 --- a/config/config.go +++ b/config/config.go @@ -3,7 +3,6 @@ package config import ( "bufio" "bytes" - "encoding/json" "errors" "fmt" "io" @@ -22,6 +21,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/currency" "github.com/thrasher-corp/gocryptotrader/currency/forexprovider" "github.com/thrasher-corp/gocryptotrader/database" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" gctscript "github.com/thrasher-corp/gocryptotrader/gctscript/vm" "github.com/thrasher-corp/gocryptotrader/log" diff --git a/currency/code.go b/currency/code.go index b14cb99cc8a..557e57a6dbf 100644 --- a/currency/code.go +++ b/currency/code.go @@ -1,11 +1,12 @@ package currency import ( - "encoding/json" "errors" "fmt" "strings" "unicode" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) var ( diff --git a/currency/code_test.go b/currency/code_test.go index d6076d590c5..74ddc993333 100644 --- a/currency/code_test.go +++ b/currency/code_test.go @@ -1,9 +1,10 @@ package currency import ( - "encoding/json" "errors" "testing" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestRoleString(t *testing.T) { diff --git a/currency/currencies.go b/currency/currencies.go index c5aa93ff538..3a46053aa65 100644 --- a/currency/currencies.go +++ b/currency/currencies.go @@ -1,8 +1,9 @@ package currency import ( - "encoding/json" "strings" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // NewCurrenciesFromStringArray returns a Currencies object from strings diff --git a/currency/currencies_test.go b/currency/currencies_test.go index 97e0e9a04a6..81c25717c21 100644 --- a/currency/currencies_test.go +++ b/currency/currencies_test.go @@ -1,10 +1,10 @@ package currency import ( - "encoding/json" "testing" "github.com/stretchr/testify/assert" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestCurrenciesUnmarshalJSON(t *testing.T) { diff --git a/currency/manager.go b/currency/manager.go index 8486aa78694..e73b865e071 100644 --- a/currency/manager.go +++ b/currency/manager.go @@ -1,7 +1,6 @@ package currency import ( - "encoding/json" "errors" "fmt" "slices" @@ -9,6 +8,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/convert" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) diff --git a/currency/manager_test.go b/currency/manager_test.go index a7064846848..400362a6b8f 100644 --- a/currency/manager_test.go +++ b/currency/manager_test.go @@ -1,13 +1,13 @@ package currency import ( - "encoding/json" "errors" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/thrasher-corp/gocryptotrader/common/convert" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) diff --git a/currency/pair_methods.go b/currency/pair_methods.go index cc732b716fe..9c0455159c2 100644 --- a/currency/pair_methods.go +++ b/currency/pair_methods.go @@ -1,10 +1,11 @@ package currency import ( - "encoding/json" "errors" "fmt" "unicode" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // EMPTYFORMAT defines an empty pair format diff --git a/currency/pair_test.go b/currency/pair_test.go index b013f29ef2b..63f0106e186 100644 --- a/currency/pair_test.go +++ b/currency/pair_test.go @@ -1,13 +1,13 @@ package currency import ( - "encoding/json" "errors" "strconv" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) const ( diff --git a/currency/pairs.go b/currency/pairs.go index 360bc8e9bb2..a5fa6d31d93 100644 --- a/currency/pairs.go +++ b/currency/pairs.go @@ -1,12 +1,13 @@ package currency import ( - "encoding/json" "errors" "fmt" "math/rand" "slices" "strings" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) var ( diff --git a/currency/pairs_test.go b/currency/pairs_test.go index 96191748cd6..3b65c95cd45 100644 --- a/currency/pairs_test.go +++ b/currency/pairs_test.go @@ -1,13 +1,13 @@ package currency import ( - "encoding/json" "errors" "slices" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestPairsUpper(t *testing.T) { diff --git a/currency/storage.go b/currency/storage.go index 930533f1a68..75674c343fe 100644 --- a/currency/storage.go +++ b/currency/storage.go @@ -1,7 +1,6 @@ package currency import ( - "encoding/json" "errors" "fmt" "os" @@ -12,6 +11,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/currency/coinmarketcap" "github.com/thrasher-corp/gocryptotrader/currency/forexprovider" "github.com/thrasher-corp/gocryptotrader/currency/forexprovider/base" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/log" ) diff --git a/encoding/json/common.go b/encoding/json/common.go new file mode 100644 index 00000000000..55f1a51f927 --- /dev/null +++ b/encoding/json/common.go @@ -0,0 +1,8 @@ +package json + +import "encoding/json" + +type ( + RawMessage = json.RawMessage + UnmarshalTypeError = json.UnmarshalTypeError // Assignment as this needs associated methods +) diff --git a/encoding/json/json.go b/encoding/json/json.go new file mode 100644 index 00000000000..39d53252674 --- /dev/null +++ b/encoding/json/json.go @@ -0,0 +1,16 @@ +//go:build !sonic + +package json + +import ( + "encoding/json" +) + +var ( + Marshal = json.Marshal + Unmarshal = json.Unmarshal + NewEncoder = json.NewEncoder + NewDecoder = json.NewDecoder + MarshalIndent = json.MarshalIndent + Valid = json.Valid +) diff --git a/encoding/json/sonic.go b/encoding/json/sonic.go new file mode 100644 index 00000000000..50a1990af2d --- /dev/null +++ b/encoding/json/sonic.go @@ -0,0 +1,16 @@ +//go:build sonic + +package json + +import ( + "github.com/bytedance/sonic" +) + +var ( + Marshal = sonic.ConfigStd.Marshal + Unmarshal = sonic.ConfigStd.Unmarshal + NewEncoder = sonic.ConfigStd.NewEncoder + NewDecoder = sonic.ConfigStd.NewDecoder + MarshalIndent = sonic.ConfigStd.MarshalIndent + Valid = sonic.ConfigStd.Valid +) diff --git a/engine/apiserver.go b/engine/apiserver.go index 462733b9c2a..fdb03e719fb 100644 --- a/engine/apiserver.go +++ b/engine/apiserver.go @@ -2,7 +2,6 @@ package engine import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -19,6 +18,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/log" ) diff --git a/engine/apiserver_test.go b/engine/apiserver_test.go index 706a03d32f6..3a25c73e721 100644 --- a/engine/apiserver_test.go +++ b/engine/apiserver_test.go @@ -1,7 +1,6 @@ package engine import ( - "encoding/json" "errors" "io" "net/http" @@ -11,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/thrasher-corp/gocryptotrader/config" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestSetupAPIServerManager(t *testing.T) { diff --git a/engine/rpcserver.go b/engine/rpcserver.go index 43b5e3814f7..eeaa4c2583b 100644 --- a/engine/rpcserver.go +++ b/engine/rpcserver.go @@ -2,7 +2,6 @@ package engine import ( "context" - "encoding/json" "errors" "fmt" "net" @@ -32,6 +31,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/database/models/sqlite3" "github.com/thrasher-corp/gocryptotrader/database/repository/audit" exchangeDB "github.com/thrasher-corp/gocryptotrader/database/repository/exchange" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" diff --git a/engine/rpcserver_test.go b/engine/rpcserver_test.go index c7d2575c955..e83de9c07ad 100644 --- a/engine/rpcserver_test.go +++ b/engine/rpcserver_test.go @@ -4,7 +4,6 @@ import ( "context" "crypto/tls" "crypto/x509" - "encoding/json" "errors" "fmt" "io" @@ -35,6 +34,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/database/repository" dbexchange "github.com/thrasher-corp/gocryptotrader/database/repository/exchange" sqltrade "github.com/thrasher-corp/gocryptotrader/database/repository/trade" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" diff --git a/exchanges/alphapoint/alphapoint.go b/exchanges/alphapoint/alphapoint.go index 03b99f95424..83549fd1de9 100644 --- a/exchanges/alphapoint/alphapoint.go +++ b/exchanges/alphapoint/alphapoint.go @@ -3,7 +3,6 @@ package alphapoint import ( "bytes" "context" - "encoding/json" "errors" "fmt" "net/http" @@ -12,6 +11,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common/crypto" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/nonce" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/alphapoint/alphapoint_test.go b/exchanges/alphapoint/alphapoint_test.go index 9630a8bd0f0..0c18a3ee1ec 100644 --- a/exchanges/alphapoint/alphapoint_test.go +++ b/exchanges/alphapoint/alphapoint_test.go @@ -2,7 +2,6 @@ package alphapoint import ( "context" - "encoding/json" "os" "testing" "time" @@ -10,6 +9,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/alphapoint/alphapoint_websocket.go b/exchanges/alphapoint/alphapoint_websocket.go index 93bc0d55024..cd318c06528 100644 --- a/exchanges/alphapoint/alphapoint_websocket.go +++ b/exchanges/alphapoint/alphapoint_websocket.go @@ -1,10 +1,10 @@ package alphapoint import ( - "encoding/json" "net/http" "github.com/gorilla/websocket" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/log" ) diff --git a/exchanges/asset/asset.go b/exchanges/asset/asset.go index e229dffeab6..d631bd61e6a 100644 --- a/exchanges/asset/asset.go +++ b/exchanges/asset/asset.go @@ -1,10 +1,11 @@ package asset import ( - "encoding/json" "errors" "fmt" "strings" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // Public errors related to assets diff --git a/exchanges/asset/asset_test.go b/exchanges/asset/asset_test.go index 1747ebf1bcb..ee9861457d5 100644 --- a/exchanges/asset/asset_test.go +++ b/exchanges/asset/asset_test.go @@ -1,11 +1,11 @@ package asset import ( - "encoding/json" "errors" "testing" "github.com/thrasher-corp/gocryptotrader/common" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestString(t *testing.T) { diff --git a/exchanges/binance/binance.go b/exchanges/binance/binance.go index 2e8aa80b030..f84f9a58fb0 100644 --- a/exchanges/binance/binance.go +++ b/exchanges/binance/binance.go @@ -2,7 +2,6 @@ package binance import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/binance/binance_cfutures.go b/exchanges/binance/binance_cfutures.go index ac09e6ada8d..2c71a7d1db4 100644 --- a/exchanges/binance/binance_cfutures.go +++ b/exchanges/binance/binance_cfutures.go @@ -2,7 +2,6 @@ package binance import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -13,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/binance/binance_test.go b/exchanges/binance/binance_test.go index a66d53b25e2..46f0da254c1 100644 --- a/exchanges/binance/binance_test.go +++ b/exchanges/binance/binance_test.go @@ -3,7 +3,6 @@ package binance import ( "bytes" "context" - "encoding/json" "errors" "fmt" "os" @@ -19,6 +18,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/key" "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/collateral" diff --git a/exchanges/binance/binance_ufutures.go b/exchanges/binance/binance_ufutures.go index 9ff95dd230e..6653e5a3a8a 100644 --- a/exchanges/binance/binance_ufutures.go +++ b/exchanges/binance/binance_ufutures.go @@ -2,7 +2,6 @@ package binance import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -13,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/binance/binance_websocket.go b/exchanges/binance/binance_websocket.go index 7c920ea9734..1cd34f45ed8 100644 --- a/exchanges/binance/binance_websocket.go +++ b/exchanges/binance/binance_websocket.go @@ -2,7 +2,6 @@ package binance import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/binance/cfutures_types_test.go b/exchanges/binance/cfutures_types_test.go index 35366a765d1..7596c1607a9 100644 --- a/exchanges/binance/cfutures_types_test.go +++ b/exchanges/binance/cfutures_types_test.go @@ -1,8 +1,9 @@ package binance import ( - "encoding/json" "testing" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestFuturesNewOrderRequest_Unmarshal(t *testing.T) { diff --git a/exchanges/binance/type_convert.go b/exchanges/binance/type_convert.go index d03453f183c..dd612e9bb20 100644 --- a/exchanges/binance/type_convert.go +++ b/exchanges/binance/type_convert.go @@ -1,10 +1,11 @@ package binance import ( - "encoding/json" "errors" "strconv" "time" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // binanceTime provides an internal conversion helper diff --git a/exchanges/binanceus/binanceus.go b/exchanges/binanceus/binanceus.go index 0d43c4f6507..34a35299b3a 100644 --- a/exchanges/binanceus/binanceus.go +++ b/exchanges/binanceus/binanceus.go @@ -2,7 +2,6 @@ package binanceus import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -16,6 +15,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" diff --git a/exchanges/binanceus/binanceus_test.go b/exchanges/binanceus/binanceus_test.go index df370b06c88..4330771f76c 100644 --- a/exchanges/binanceus/binanceus_test.go +++ b/exchanges/binanceus/binanceus_test.go @@ -2,7 +2,6 @@ package binanceus import ( "context" - "encoding/json" "errors" "log" "os" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" diff --git a/exchanges/binanceus/binanceus_websocket.go b/exchanges/binanceus/binanceus_websocket.go index d10cfe84c11..534c4266616 100644 --- a/exchanges/binanceus/binanceus_websocket.go +++ b/exchanges/binanceus/binanceus_websocket.go @@ -2,7 +2,6 @@ package binanceus import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -12,6 +11,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/binanceus/type_convert.go b/exchanges/binanceus/type_convert.go index 4873f53526f..a831e5e4822 100644 --- a/exchanges/binanceus/type_convert.go +++ b/exchanges/binanceus/type_convert.go @@ -1,8 +1,9 @@ package binanceus import ( - "encoding/json" "time" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // UnmarshalJSON deserialises the JSON info, including the timestamp diff --git a/exchanges/bitfinex/bitfinex.go b/exchanges/bitfinex/bitfinex.go index 528e61080ba..2091b7434f7 100644 --- a/exchanges/bitfinex/bitfinex.go +++ b/exchanges/bitfinex/bitfinex.go @@ -3,7 +3,6 @@ package bitfinex import ( "bytes" "context" - "encoding/json" "errors" "fmt" "io" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/nonce" diff --git a/exchanges/bitfinex/bitfinex_websocket.go b/exchanges/bitfinex/bitfinex_websocket.go index 8b0899cd67e..981d7036c8c 100644 --- a/exchanges/bitfinex/bitfinex_websocket.go +++ b/exchanges/bitfinex/bitfinex_websocket.go @@ -2,7 +2,6 @@ package bitfinex import ( "context" - "encoding/json" "errors" "fmt" "hash/crc32" @@ -19,6 +18,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/bithumb/bithumb.go b/exchanges/bithumb/bithumb.go index 6ebfd2848da..89bc187211b 100644 --- a/exchanges/bithumb/bithumb.go +++ b/exchanges/bithumb/bithumb.go @@ -3,7 +3,6 @@ package bithumb import ( "bytes" "context" - "encoding/json" "errors" "fmt" "math" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/bithumb/bithumb_types.go b/exchanges/bithumb/bithumb_types.go index 5299a454088..8d777455719 100644 --- a/exchanges/bithumb/bithumb_types.go +++ b/exchanges/bithumb/bithumb_types.go @@ -1,9 +1,8 @@ package bithumb import ( - "encoding/json" - "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // Ticker holds ticker data diff --git a/exchanges/bithumb/bithumb_websocket.go b/exchanges/bithumb/bithumb_websocket.go index 929d68a61e2..246d0184e91 100644 --- a/exchanges/bithumb/bithumb_websocket.go +++ b/exchanges/bithumb/bithumb_websocket.go @@ -1,13 +1,13 @@ package bithumb import ( - "encoding/json" "fmt" "net/http" "time" "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/stream" "github.com/thrasher-corp/gocryptotrader/exchanges/subscription" diff --git a/exchanges/bithumb/bithumb_websocket_types.go b/exchanges/bithumb/bithumb_websocket_types.go index bb8fb4268eb..e5b17b5ef9d 100644 --- a/exchanges/bithumb/bithumb_websocket_types.go +++ b/exchanges/bithumb/bithumb_websocket_types.go @@ -1,11 +1,11 @@ package bithumb import ( - "encoding/json" "sync" "time" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" ) diff --git a/exchanges/bithumb/convert.go b/exchanges/bithumb/convert.go index 7efac458de9..e9fb861cf28 100644 --- a/exchanges/bithumb/convert.go +++ b/exchanges/bithumb/convert.go @@ -1,9 +1,10 @@ package bithumb import ( - "encoding/json" "strconv" "time" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // bithumbMSTime provides an internal conversion helper for microsecond parsing diff --git a/exchanges/bithumb/convert_test.go b/exchanges/bithumb/convert_test.go index 74326af31b9..4cc77d9cb93 100644 --- a/exchanges/bithumb/convert_test.go +++ b/exchanges/bithumb/convert_test.go @@ -1,8 +1,9 @@ package bithumb import ( - "encoding/json" "testing" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestBithumbTime(t *testing.T) { diff --git a/exchanges/bitmex/bitmex.go b/exchanges/bitmex/bitmex.go index 73bd5637d82..0a6073a0a07 100644 --- a/exchanges/bitmex/bitmex.go +++ b/exchanges/bitmex/bitmex.go @@ -2,7 +2,6 @@ package bitmex import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -13,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/request" ) diff --git a/exchanges/bitmex/bitmex_websocket.go b/exchanges/bitmex/bitmex_websocket.go index 6779a97a1e9..46574068036 100644 --- a/exchanges/bitmex/bitmex_websocket.go +++ b/exchanges/bitmex/bitmex_websocket.go @@ -2,7 +2,6 @@ package bitmex import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -13,6 +12,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/bitstamp/bitstamp.go b/exchanges/bitstamp/bitstamp.go index bfcb7ea02e9..bdd7f0de363 100644 --- a/exchanges/bitstamp/bitstamp.go +++ b/exchanges/bitstamp/bitstamp.go @@ -3,7 +3,6 @@ package bitstamp import ( "bytes" "context" - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/nonce" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/bitstamp/bitstamp_type_convert.go b/exchanges/bitstamp/bitstamp_type_convert.go index 94af150ffe0..c25b962cc69 100644 --- a/exchanges/bitstamp/bitstamp_type_convert.go +++ b/exchanges/bitstamp/bitstamp_type_convert.go @@ -1,13 +1,13 @@ package bitstamp import ( - "encoding/json" "fmt" "strconv" "strings" "time" "github.com/thrasher-corp/gocryptotrader/common/convert" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/order" ) diff --git a/exchanges/bitstamp/bitstamp_websocket.go b/exchanges/bitstamp/bitstamp_websocket.go index ab887e422a3..ed09ab59208 100644 --- a/exchanges/bitstamp/bitstamp_websocket.go +++ b/exchanges/bitstamp/bitstamp_websocket.go @@ -2,7 +2,6 @@ package bitstamp import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -13,6 +12,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/btcmarkets/btcmarkets.go b/exchanges/btcmarkets/btcmarkets.go index b8425d4814c..9f0e466a180 100644 --- a/exchanges/btcmarkets/btcmarkets.go +++ b/exchanges/btcmarkets/btcmarkets.go @@ -3,7 +3,6 @@ package btcmarkets import ( "bytes" "context" - "encoding/json" "errors" "fmt" "io" @@ -16,6 +15,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/request" diff --git a/exchanges/btcmarkets/btcmarkets_websocket.go b/exchanges/btcmarkets/btcmarkets_websocket.go index f6e415ab3b1..9ea48f5fe8e 100644 --- a/exchanges/btcmarkets/btcmarkets_websocket.go +++ b/exchanges/btcmarkets/btcmarkets_websocket.go @@ -2,7 +2,6 @@ package btcmarkets import ( "context" - "encoding/json" "errors" "fmt" "hash/crc32" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/btse/btse.go b/exchanges/btse/btse.go index 9ea912abbda..1f963f84dcc 100644 --- a/exchanges/btse/btse.go +++ b/exchanges/btse/btse.go @@ -3,7 +3,6 @@ package btse import ( "bytes" "context" - "encoding/json" "errors" "io" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/request" diff --git a/exchanges/btse/btse_websocket.go b/exchanges/btse/btse_websocket.go index 4bac49517bb..fcc516dc416 100644 --- a/exchanges/btse/btse_websocket.go +++ b/exchanges/btse/btse_websocket.go @@ -2,7 +2,6 @@ package btse import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -13,6 +12,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/bybit/bybit.go b/exchanges/bybit/bybit.go index ad882ff168f..27bf2e65666 100644 --- a/exchanges/bybit/bybit.go +++ b/exchanges/bybit/bybit.go @@ -3,7 +3,6 @@ package bybit import ( "bytes" "context" - "encoding/json" "errors" "fmt" "net/http" @@ -16,6 +15,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/bybit/bybit_convert.go b/exchanges/bybit/bybit_convert.go index d28816fafde..cf1ea3d60e4 100644 --- a/exchanges/bybit/bybit_convert.go +++ b/exchanges/bybit/bybit_convert.go @@ -1,6 +1,6 @@ package bybit -import "encoding/json" +import "github.com/thrasher-corp/gocryptotrader/encoding/json" // UnmarshalJSON deserializes incoming data into orderbookResponse instance. func (a *orderbookResponse) UnmarshalJSON(data []byte) error { diff --git a/exchanges/bybit/bybit_options_websocket.go b/exchanges/bybit/bybit_options_websocket.go index 72a86b0c9c6..b9a9d6e1986 100644 --- a/exchanges/bybit/bybit_options_websocket.go +++ b/exchanges/bybit/bybit_options_websocket.go @@ -1,12 +1,12 @@ package bybit import ( - "encoding/json" "net/http" "strconv" "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/stream" "github.com/thrasher-corp/gocryptotrader/exchanges/subscription" diff --git a/exchanges/bybit/bybit_test.go b/exchanges/bybit/bybit_test.go index 437c4a92bae..c9cdc4ad455 100644 --- a/exchanges/bybit/bybit_test.go +++ b/exchanges/bybit/bybit_test.go @@ -2,7 +2,6 @@ package bybit import ( "context" - "encoding/json" "errors" "slices" "testing" @@ -13,6 +12,7 @@ import ( "github.com/stretchr/testify/require" "github.com/thrasher-corp/gocryptotrader/common/key" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/fundingrate" diff --git a/exchanges/bybit/bybit_types.go b/exchanges/bybit/bybit_types.go index fd2f8cdfce3..6655227a232 100644 --- a/exchanges/bybit/bybit_types.go +++ b/exchanges/bybit/bybit_types.go @@ -1,12 +1,12 @@ package bybit import ( - "encoding/json" "time" "github.com/gofrs/uuid" "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" "github.com/thrasher-corp/gocryptotrader/types" ) diff --git a/exchanges/bybit/bybit_websocket.go b/exchanges/bybit/bybit_websocket.go index 9e6308f2e43..5e93d4bb14f 100644 --- a/exchanges/bybit/bybit_websocket.go +++ b/exchanges/bybit/bybit_websocket.go @@ -2,7 +2,6 @@ package bybit import ( "context" - "encoding/json" "fmt" "net/http" "strconv" @@ -12,6 +11,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/fill" diff --git a/exchanges/coinbasepro/coinbasepro.go b/exchanges/coinbasepro/coinbasepro.go index 31308e77ae7..0dd688019eb 100644 --- a/exchanges/coinbasepro/coinbasepro.go +++ b/exchanges/coinbasepro/coinbasepro.go @@ -3,7 +3,6 @@ package coinbasepro import ( "bytes" "context" - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/request" diff --git a/exchanges/coinbasepro/coinbasepro_websocket.go b/exchanges/coinbasepro/coinbasepro_websocket.go index 4765eba59b5..08e7e14182d 100644 --- a/exchanges/coinbasepro/coinbasepro_websocket.go +++ b/exchanges/coinbasepro/coinbasepro_websocket.go @@ -2,7 +2,6 @@ package coinbasepro import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -13,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/coinut/coinut.go b/exchanges/coinut/coinut.go index f80a353b691..db6042ca133 100644 --- a/exchanges/coinut/coinut.go +++ b/exchanges/coinut/coinut.go @@ -3,7 +3,6 @@ package coinut import ( "bytes" "context" - "encoding/json" "errors" "fmt" "math/rand" @@ -13,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" diff --git a/exchanges/coinut/coinut_websocket.go b/exchanges/coinut/coinut_websocket.go index ec74b7d2f5b..f6efafd799c 100644 --- a/exchanges/coinut/coinut_websocket.go +++ b/exchanges/coinut/coinut_websocket.go @@ -2,7 +2,6 @@ package coinut import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/collateral/collateral.go b/exchanges/collateral/collateral.go index 77b045b2a4e..935d056e99c 100644 --- a/exchanges/collateral/collateral.go +++ b/exchanges/collateral/collateral.go @@ -1,9 +1,10 @@ package collateral import ( - "encoding/json" "fmt" "strings" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // Valid returns whether the collateral mode is valid diff --git a/exchanges/collateral/collateral_test.go b/exchanges/collateral/collateral_test.go index 60aae825a53..02a3c251939 100644 --- a/exchanges/collateral/collateral_test.go +++ b/exchanges/collateral/collateral_test.go @@ -1,10 +1,11 @@ package collateral import ( - "encoding/json" "errors" "strings" "testing" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestValidCollateralType(t *testing.T) { diff --git a/exchanges/deribit/deribit.go b/exchanges/deribit/deribit.go index f4787df6be4..df4d0aa418a 100644 --- a/exchanges/deribit/deribit.go +++ b/exchanges/deribit/deribit.go @@ -2,7 +2,6 @@ package deribit import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" diff --git a/exchanges/deribit/deribit_test.go b/exchanges/deribit/deribit_test.go index 84b92c7b2d2..34e4d3dd7f3 100644 --- a/exchanges/deribit/deribit_test.go +++ b/exchanges/deribit/deribit_test.go @@ -2,7 +2,6 @@ package deribit import ( "context" - "encoding/json" "fmt" "log" "os" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/key" "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/fundingrate" diff --git a/exchanges/deribit/deribit_types.go b/exchanges/deribit/deribit_types.go index 9af38187272..6b98188f5cf 100644 --- a/exchanges/deribit/deribit_types.go +++ b/exchanges/deribit/deribit_types.go @@ -1,12 +1,12 @@ package deribit import ( - "encoding/json" "errors" "regexp" "time" "github.com/thrasher-corp/gocryptotrader/common/convert" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/types" ) diff --git a/exchanges/deribit/deribit_websocket.go b/exchanges/deribit/deribit_websocket.go index 9c096022c2c..90e2a8788b7 100644 --- a/exchanges/deribit/deribit_websocket.go +++ b/exchanges/deribit/deribit_websocket.go @@ -2,7 +2,6 @@ package deribit import ( "context" - "encoding/json" "fmt" "net/http" "strconv" @@ -13,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" "github.com/thrasher-corp/gocryptotrader/exchanges/nonce" diff --git a/exchanges/deribit/deribit_websocket_eps.go b/exchanges/deribit/deribit_websocket_eps.go index 4c639cc60e4..e76bc9cea60 100644 --- a/exchanges/deribit/deribit_websocket_eps.go +++ b/exchanges/deribit/deribit_websocket_eps.go @@ -2,7 +2,6 @@ package deribit import ( "context" - "encoding/json" "errors" "fmt" "net/url" @@ -11,6 +10,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/request" diff --git a/exchanges/gateio/gateio.go b/exchanges/gateio/gateio.go index 0555e814e0d..ab7a2689992 100644 --- a/exchanges/gateio/gateio.go +++ b/exchanges/gateio/gateio.go @@ -5,7 +5,6 @@ import ( "crypto/hmac" "crypto/sha512" "encoding/hex" - "encoding/json" "errors" "fmt" "net/http" @@ -16,6 +15,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" diff --git a/exchanges/gateio/gateio_convert.go b/exchanges/gateio/gateio_convert.go index 4c9aea3d457..72f50bc18a1 100644 --- a/exchanges/gateio/gateio_convert.go +++ b/exchanges/gateio/gateio_convert.go @@ -1,11 +1,12 @@ package gateio import ( - "encoding/json" "fmt" "math" "strconv" "time" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // Time represents a time.Time object that can be unmarshalled from a float64 or string. diff --git a/exchanges/gateio/gateio_test.go b/exchanges/gateio/gateio_test.go index ca6b5b55c6c..fc515b96b1d 100644 --- a/exchanges/gateio/gateio_test.go +++ b/exchanges/gateio/gateio_test.go @@ -2,7 +2,6 @@ package gateio import ( "context" - "encoding/json" "errors" "log" "os" @@ -18,6 +17,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/fundingrate" "github.com/thrasher-corp/gocryptotrader/exchanges/futures" diff --git a/exchanges/gateio/gateio_types.go b/exchanges/gateio/gateio_types.go index f4c48fa3ab3..90a13d5e73d 100644 --- a/exchanges/gateio/gateio_types.go +++ b/exchanges/gateio/gateio_types.go @@ -1,11 +1,11 @@ package gateio import ( - "encoding/json" "strconv" "time" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/types" ) diff --git a/exchanges/gateio/gateio_websocket.go b/exchanges/gateio/gateio_websocket.go index 537c695ba7b..fa1f1781abc 100644 --- a/exchanges/gateio/gateio_websocket.go +++ b/exchanges/gateio/gateio_websocket.go @@ -5,7 +5,6 @@ import ( "crypto/hmac" "crypto/sha512" "encoding/hex" - "encoding/json" "errors" "fmt" "net/http" @@ -16,6 +15,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/fill" diff --git a/exchanges/gateio/gateio_ws_delivery_futures.go b/exchanges/gateio/gateio_ws_delivery_futures.go index 1a41e21a883..dd7d9dbc3dd 100644 --- a/exchanges/gateio/gateio_ws_delivery_futures.go +++ b/exchanges/gateio/gateio_ws_delivery_futures.go @@ -2,7 +2,6 @@ package gateio import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -13,6 +12,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" diff --git a/exchanges/gateio/gateio_ws_futures.go b/exchanges/gateio/gateio_ws_futures.go index 167e9884295..b85fe9d0888 100644 --- a/exchanges/gateio/gateio_ws_futures.go +++ b/exchanges/gateio/gateio_ws_futures.go @@ -2,7 +2,6 @@ package gateio import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -13,6 +12,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/fill" diff --git a/exchanges/gateio/gateio_ws_option.go b/exchanges/gateio/gateio_ws_option.go index 55b7a720e70..37a24603c9a 100644 --- a/exchanges/gateio/gateio_ws_option.go +++ b/exchanges/gateio/gateio_ws_option.go @@ -2,7 +2,6 @@ package gateio import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -13,6 +12,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/fill" diff --git a/exchanges/gemini/gemini.go b/exchanges/gemini/gemini.go index e6cce565302..4c646d23958 100644 --- a/exchanges/gemini/gemini.go +++ b/exchanges/gemini/gemini.go @@ -2,7 +2,6 @@ package gemini import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -14,6 +13,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/nonce" "github.com/thrasher-corp/gocryptotrader/exchanges/request" diff --git a/exchanges/gemini/gemini_websocket.go b/exchanges/gemini/gemini_websocket.go index 566611bce1a..a1012c66994 100644 --- a/exchanges/gemini/gemini_websocket.go +++ b/exchanges/gemini/gemini_websocket.go @@ -4,7 +4,6 @@ package gemini import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/hitbtc/hitbtc_websocket.go b/exchanges/hitbtc/hitbtc_websocket.go index 68f68de93be..8d5d14685f4 100644 --- a/exchanges/hitbtc/hitbtc_websocket.go +++ b/exchanges/hitbtc/hitbtc_websocket.go @@ -2,7 +2,6 @@ package hitbtc import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -14,6 +13,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/huobi/huobi.go b/exchanges/huobi/huobi.go index 467d25f3025..0244412ce6f 100644 --- a/exchanges/huobi/huobi.go +++ b/exchanges/huobi/huobi.go @@ -3,7 +3,6 @@ package huobi import ( "bytes" "context" - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/request" diff --git a/exchanges/huobi/huobi_futures.go b/exchanges/huobi/huobi_futures.go index 36d2a836f0a..2baeace665c 100644 --- a/exchanges/huobi/huobi_futures.go +++ b/exchanges/huobi/huobi_futures.go @@ -3,7 +3,6 @@ package huobi import ( "bytes" "context" - "encoding/json" "errors" "fmt" "io" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/huobi/huobi_websocket.go b/exchanges/huobi/huobi_websocket.go index 3c86ac62e1e..44a681e85ed 100644 --- a/exchanges/huobi/huobi_websocket.go +++ b/exchanges/huobi/huobi_websocket.go @@ -2,7 +2,6 @@ package huobi import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/kraken/kraken.go b/exchanges/kraken/kraken.go index 28b1f405428..11423b3b5ba 100644 --- a/exchanges/kraken/kraken.go +++ b/exchanges/kraken/kraken.go @@ -2,7 +2,6 @@ package kraken import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -16,6 +15,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/nonce" diff --git a/exchanges/kraken/kraken_futures.go b/exchanges/kraken/kraken_futures.go index 85b6c45e74d..327f251daf6 100644 --- a/exchanges/kraken/kraken_futures.go +++ b/exchanges/kraken/kraken_futures.go @@ -3,7 +3,6 @@ package kraken import ( "context" "encoding/base64" - "encoding/json" "errors" "fmt" "net/http" @@ -14,6 +13,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/kraken/kraken_test.go b/exchanges/kraken/kraken_test.go index 16e1459c76d..23c9d7be8f0 100644 --- a/exchanges/kraken/kraken_test.go +++ b/exchanges/kraken/kraken_test.go @@ -2,7 +2,6 @@ package kraken import ( "context" - "encoding/json" "errors" "fmt" "log" @@ -20,6 +19,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/key" "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/fundingrate" diff --git a/exchanges/kraken/kraken_types.go b/exchanges/kraken/kraken_types.go index 595f71ddc27..090067ae0f7 100644 --- a/exchanges/kraken/kraken_types.go +++ b/exchanges/kraken/kraken_types.go @@ -1,7 +1,6 @@ package kraken import ( - "encoding/json" "errors" "fmt" "strings" @@ -9,6 +8,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/subscription" "github.com/thrasher-corp/gocryptotrader/types" diff --git a/exchanges/kraken/kraken_websocket.go b/exchanges/kraken/kraken_websocket.go index 1646adb0a83..1fe2c572878 100644 --- a/exchanges/kraken/kraken_websocket.go +++ b/exchanges/kraken/kraken_websocket.go @@ -2,7 +2,6 @@ package kraken import ( "context" - "encoding/json" "errors" "fmt" "hash/crc32" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/kucoin/kucoin.go b/exchanges/kucoin/kucoin.go index 53a1389459c..2daac7dff94 100644 --- a/exchanges/kucoin/kucoin.go +++ b/exchanges/kucoin/kucoin.go @@ -3,7 +3,6 @@ package kucoin import ( "bytes" "context" - "encoding/json" "errors" "fmt" "io" @@ -20,6 +19,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" diff --git a/exchanges/kucoin/kucoin_convert.go b/exchanges/kucoin/kucoin_convert.go index 83b8bd5d5ae..807c4ef9e1c 100644 --- a/exchanges/kucoin/kucoin_convert.go +++ b/exchanges/kucoin/kucoin_convert.go @@ -1,8 +1,9 @@ package kucoin import ( - "encoding/json" "fmt" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // UnmarshalJSON valid data to SubAccountsResponse of return nil if the data is empty list. diff --git a/exchanges/kucoin/kucoin_test.go b/exchanges/kucoin/kucoin_test.go index 863c239ce05..acc92edc7ab 100644 --- a/exchanges/kucoin/kucoin_test.go +++ b/exchanges/kucoin/kucoin_test.go @@ -2,7 +2,6 @@ package kucoin import ( "context" - "encoding/json" "errors" "log" "os" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/fundingrate" diff --git a/exchanges/kucoin/kucoin_types.go b/exchanges/kucoin/kucoin_types.go index 1d710c098c3..9c13c33ddd0 100644 --- a/exchanges/kucoin/kucoin_types.go +++ b/exchanges/kucoin/kucoin_types.go @@ -1,7 +1,6 @@ package kucoin import ( - "encoding/json" "errors" "fmt" "regexp" @@ -10,6 +9,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" "github.com/thrasher-corp/gocryptotrader/types" ) diff --git a/exchanges/kucoin/kucoin_websocket.go b/exchanges/kucoin/kucoin_websocket.go index f21a7c7376b..48499db19aa 100644 --- a/exchanges/kucoin/kucoin_websocket.go +++ b/exchanges/kucoin/kucoin_websocket.go @@ -2,7 +2,6 @@ package kucoin import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -17,6 +16,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" diff --git a/exchanges/lbank/lbank.go b/exchanges/lbank/lbank.go index b5e88d03686..068e7ba9e04 100644 --- a/exchanges/lbank/lbank.go +++ b/exchanges/lbank/lbank.go @@ -7,7 +7,6 @@ import ( "crypto/rand" "crypto/rsa" "crypto/x509" - "encoding/json" "encoding/pem" "errors" "fmt" @@ -18,6 +17,7 @@ import ( "time" gctcrypto "github.com/thrasher-corp/gocryptotrader/common/crypto" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/request" diff --git a/exchanges/lbank/lbank_types.go b/exchanges/lbank/lbank_types.go index dc6e03282df..62b5d945858 100644 --- a/exchanges/lbank/lbank_types.go +++ b/exchanges/lbank/lbank_types.go @@ -1,10 +1,10 @@ package lbank import ( - "encoding/json" "time" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // Ticker stores the ticker price data for a currency pair diff --git a/exchanges/margin/margin.go b/exchanges/margin/margin.go index bba28157506..4a2bf8a71f7 100644 --- a/exchanges/margin/margin.go +++ b/exchanges/margin/margin.go @@ -1,9 +1,10 @@ package margin import ( - "encoding/json" "fmt" "strings" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // Valid returns whether the margin type is valid diff --git a/exchanges/margin/margin_test.go b/exchanges/margin/margin_test.go index 2c14b6ffeaa..25b5fac6f44 100644 --- a/exchanges/margin/margin_test.go +++ b/exchanges/margin/margin_test.go @@ -1,10 +1,11 @@ package margin import ( - "encoding/json" "errors" "strings" "testing" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestValid(t *testing.T) { diff --git a/exchanges/mock/common.go b/exchanges/mock/common.go index 0f77a1931f0..4f8c34ee34d 100644 --- a/exchanges/mock/common.go +++ b/exchanges/mock/common.go @@ -1,7 +1,6 @@ package mock import ( - "encoding/json" "errors" "fmt" "log" @@ -9,6 +8,8 @@ import ( "reflect" "strconv" "strings" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // MatchURLVals matches url.Value query strings diff --git a/exchanges/mock/common_test.go b/exchanges/mock/common_test.go index ae7ede80c8f..4703655c5fe 100644 --- a/exchanges/mock/common_test.go +++ b/exchanges/mock/common_test.go @@ -1,9 +1,10 @@ package mock import ( - "encoding/json" "net/url" "testing" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestMatchURLVals(t *testing.T) { diff --git a/exchanges/mock/recording.go b/exchanges/mock/recording.go index a8bc37be134..f009c1bdd65 100644 --- a/exchanges/mock/recording.go +++ b/exchanges/mock/recording.go @@ -1,7 +1,6 @@ package mock import ( - "encoding/json" "errors" "fmt" "io" @@ -16,6 +15,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/common/file" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // HTTPResponse defines expected response from the end point including request diff --git a/exchanges/mock/recording_test.go b/exchanges/mock/recording_test.go index 5b61229529a..01de889a909 100644 --- a/exchanges/mock/recording_test.go +++ b/exchanges/mock/recording_test.go @@ -1,11 +1,12 @@ package mock import ( - "encoding/json" "net/http" "net/url" "strings" "testing" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestGetFilteredHeader(t *testing.T) { diff --git a/exchanges/mock/server.go b/exchanges/mock/server.go index 1881fec7696..9cdbeec70c0 100644 --- a/exchanges/mock/server.go +++ b/exchanges/mock/server.go @@ -1,7 +1,6 @@ package mock import ( - "encoding/json" "errors" "fmt" "io" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/common/file" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // DefaultDirectory defines the main mock directory diff --git a/exchanges/mock/server_test.go b/exchanges/mock/server_test.go index 5b9cb8cf502..27c197c4b49 100644 --- a/exchanges/mock/server_test.go +++ b/exchanges/mock/server_test.go @@ -3,13 +3,13 @@ package mock import ( "bytes" "context" - "encoding/json" "net/http" "os" "strings" "testing" "github.com/thrasher-corp/gocryptotrader/common" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) type responsePayload struct { diff --git a/exchanges/okcoin/okcoin.go b/exchanges/okcoin/okcoin.go index d37f104d7c1..14a8036e608 100644 --- a/exchanges/okcoin/okcoin.go +++ b/exchanges/okcoin/okcoin.go @@ -3,7 +3,6 @@ package okcoin import ( "bytes" "context" - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" diff --git a/exchanges/okcoin/okcoin_convert.go b/exchanges/okcoin/okcoin_convert.go index d13aa16e598..a62255efcba 100644 --- a/exchanges/okcoin/okcoin_convert.go +++ b/exchanges/okcoin/okcoin_convert.go @@ -1,10 +1,11 @@ package okcoin import ( - "encoding/json" "fmt" "strconv" "time" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) type okcoinTime time.Time diff --git a/exchanges/okcoin/okcoin_websocket.go b/exchanges/okcoin/okcoin_websocket.go index 2c02e2a8460..f4fc645266b 100644 --- a/exchanges/okcoin/okcoin_websocket.go +++ b/exchanges/okcoin/okcoin_websocket.go @@ -3,7 +3,6 @@ package okcoin import ( "bytes" "context" - "encoding/json" "errors" "fmt" "hash/crc32" @@ -15,6 +14,7 @@ import ( "github.com/gorilla/websocket" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" diff --git a/exchanges/okcoin/okcoin_ws_trade.go b/exchanges/okcoin/okcoin_ws_trade.go index 054396ceb71..e9cc66a2f04 100644 --- a/exchanges/okcoin/okcoin_ws_trade.go +++ b/exchanges/okcoin/okcoin_ws_trade.go @@ -2,12 +2,12 @@ package okcoin import ( "context" - "encoding/json" "errors" "fmt" "reflect" "strconv" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/stream" ) diff --git a/exchanges/okx/okx.go b/exchanges/okx/okx.go index a3bbe1a552c..ffe8d513a24 100644 --- a/exchanges/okx/okx.go +++ b/exchanges/okx/okx.go @@ -3,7 +3,6 @@ package okx import ( "bytes" "context" - "encoding/json" "errors" "fmt" "net" @@ -18,6 +17,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" diff --git a/exchanges/okx/okx_test.go b/exchanges/okx/okx_test.go index 7a34c7d4b64..4398afbc1f1 100644 --- a/exchanges/okx/okx_test.go +++ b/exchanges/okx/okx_test.go @@ -2,7 +2,6 @@ package okx import ( "context" - "encoding/json" "errors" "fmt" "log" @@ -18,6 +17,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/collateral" diff --git a/exchanges/okx/okx_type_convert.go b/exchanges/okx/okx_type_convert.go index 791b9c680de..468aa19b155 100644 --- a/exchanges/okx/okx_type_convert.go +++ b/exchanges/okx/okx_type_convert.go @@ -1,11 +1,11 @@ package okx import ( - "encoding/json" "strconv" "strings" "time" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/order" ) diff --git a/exchanges/okx/okx_types.go b/exchanges/okx/okx_types.go index b7b0e1dc054..e0dce71970a 100644 --- a/exchanges/okx/okx_types.go +++ b/exchanges/okx/okx_types.go @@ -1,12 +1,12 @@ package okx import ( - "encoding/json" "strconv" "time" "github.com/thrasher-corp/gocryptotrader/common/convert" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/okx/okx_websocket.go b/exchanges/okx/okx_websocket.go index 1758d17d1cd..b5f6b5c10ba 100644 --- a/exchanges/okx/okx_websocket.go +++ b/exchanges/okx/okx_websocket.go @@ -3,7 +3,6 @@ package okx import ( "bytes" "context" - "encoding/json" "errors" "fmt" "hash/crc32" @@ -16,6 +15,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/orderbook" diff --git a/exchanges/order/order_test.go b/exchanges/order/order_test.go index 04c0258d44a..21fe2983f11 100644 --- a/exchanges/order/order_test.go +++ b/exchanges/order/order_test.go @@ -1,7 +1,6 @@ package order import ( - "encoding/json" "errors" "fmt" "reflect" @@ -15,6 +14,7 @@ import ( "github.com/stretchr/testify/require" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/protocol" "github.com/thrasher-corp/gocryptotrader/exchanges/validate" diff --git a/exchanges/order/orders.go b/exchanges/order/orders.go index 5f92b802308..9594f3bad7c 100644 --- a/exchanges/order/orders.go +++ b/exchanges/order/orders.go @@ -2,7 +2,6 @@ package order import ( "bytes" - "encoding/json" "errors" "fmt" "reflect" @@ -13,6 +12,7 @@ import ( "github.com/gofrs/uuid" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/protocol" "github.com/thrasher-corp/gocryptotrader/exchanges/validate" diff --git a/exchanges/poloniex/poloniex.go b/exchanges/poloniex/poloniex.go index 4f95e53dff8..d5286c4a169 100644 --- a/exchanges/poloniex/poloniex.go +++ b/exchanges/poloniex/poloniex.go @@ -3,7 +3,6 @@ package poloniex import ( "bytes" "context" - "encoding/json" "errors" "fmt" "net/http" @@ -15,6 +14,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/nonce" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/poloniex/poloniex_types.go b/exchanges/poloniex/poloniex_types.go index e28c27912e9..ede3fa8bdb9 100644 --- a/exchanges/poloniex/poloniex_types.go +++ b/exchanges/poloniex/poloniex_types.go @@ -1,10 +1,10 @@ package poloniex import ( - "encoding/json" "time" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // Ticker holds ticker data diff --git a/exchanges/poloniex/poloniex_websocket.go b/exchanges/poloniex/poloniex_websocket.go index a5407915519..fb0af330c4d 100644 --- a/exchanges/poloniex/poloniex_websocket.go +++ b/exchanges/poloniex/poloniex_websocket.go @@ -2,7 +2,6 @@ package poloniex import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -14,6 +13,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/account" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" diff --git a/exchanges/request/request.go b/exchanges/request/request.go index 9c0b5c86e9b..10af5ea591e 100644 --- a/exchanges/request/request.go +++ b/exchanges/request/request.go @@ -2,7 +2,6 @@ package request import ( "context" - "encoding/json" "errors" "fmt" "io" @@ -13,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/timedmutex" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/mock" "github.com/thrasher-corp/gocryptotrader/exchanges/nonce" "github.com/thrasher-corp/gocryptotrader/log" diff --git a/exchanges/stream/websocket_connection.go b/exchanges/stream/websocket_connection.go index 37a5aecd25b..8a06e3e88c1 100644 --- a/exchanges/stream/websocket_connection.go +++ b/exchanges/stream/websocket_connection.go @@ -6,7 +6,6 @@ import ( "compress/gzip" "context" "crypto/rand" - "encoding/json" "fmt" "io" "math/big" @@ -17,6 +16,7 @@ import ( "time" "github.com/gorilla/websocket" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/log" ) diff --git a/exchanges/stream/websocket_test.go b/exchanges/stream/websocket_test.go index 324f3e3255d..37392cf3e32 100644 --- a/exchanges/stream/websocket_test.go +++ b/exchanges/stream/websocket_test.go @@ -5,7 +5,6 @@ import ( "compress/flate" "compress/gzip" "context" - "encoding/json" "errors" "fmt" "net" @@ -23,6 +22,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/protocol" "github.com/thrasher-corp/gocryptotrader/exchanges/subscription" ) diff --git a/exchanges/subscription/subscription_test.go b/exchanges/subscription/subscription_test.go index edc828a8b22..d34cb70efc4 100644 --- a/exchanges/subscription/subscription_test.go +++ b/exchanges/subscription/subscription_test.go @@ -1,11 +1,11 @@ package subscription import ( - "encoding/json" "testing" "github.com/stretchr/testify/assert" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" ) diff --git a/go.mod b/go.mod index 3b71251f340..e92f71f3572 100644 --- a/go.mod +++ b/go.mod @@ -34,11 +34,16 @@ require ( require ( github.com/boombuler/barcode v1.0.1 // indirect + github.com/bytedance/sonic v1.12.1 // indirect + github.com/bytedance/sonic/loader v0.2.0 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/friendsofgo/errors v0.9.2 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/klauspost/cpuid/v2 v2.0.9 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect @@ -51,11 +56,13 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/volatiletech/inflect v0.0.1 // indirect github.com/volatiletech/sqlboiler v3.7.1+incompatible // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect + golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/sys v0.23.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect diff --git a/go.sum b/go.sum index df96d2a7bce..ed3769cf93e 100644 --- a/go.sum +++ b/go.sum @@ -20,9 +20,18 @@ github.com/boombuler/barcode v1.0.1 h1:NDBbPmhS+EqABEs5Kg3n/5ZNjy73Pz7SIV+KCeqyX github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= +github.com/bytedance/sonic v1.12.1 h1:jWl5Qz1fy7X1ioY74WqO0KjAMtAGQs4sYnjiEBiyX24= +github.com/bytedance/sonic v1.12.1/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= +github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -105,6 +114,9 @@ github.com/kat-co/vala v0.0.0-20170210184112-42e1d8b61f12/go.mod h1:u9MdXq/QageO github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -202,6 +214,7 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -214,6 +227,8 @@ github.com/thrasher-corp/goose v2.7.0-rc4.0.20191002032028-0f2c2a27abdb+incompat github.com/thrasher-corp/sqlboiler v1.0.1-0.20191001234224-71e17f37a85e h1:4kYBo2YhqqFY7aZPPEhrtPTMoAq4iCsoDITd3jseRbY= github.com/thrasher-corp/sqlboiler v1.0.1-0.20191001234224-71e17f37a85e/go.mod h1:JfJE+3gijF30ZJbUCzxGkU0+ymQxBfBOVp4XDObmJBE= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8= @@ -244,6 +259,8 @@ go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -358,3 +375,4 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= diff --git a/log/logger_multiwriter.go b/log/logger_multiwriter.go index 308051bae3b..794ae91276c 100644 --- a/log/logger_multiwriter.go +++ b/log/logger_multiwriter.go @@ -1,12 +1,13 @@ package log import ( - "encoding/json" "errors" "fmt" "io" "log" "time" + + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) var ( diff --git a/log/logger_test.go b/log/logger_test.go index 0f2c91b6c44..f0cae757062 100644 --- a/log/logger_test.go +++ b/log/logger_test.go @@ -1,7 +1,6 @@ package log import ( - "encoding/json" "errors" "io" "log" @@ -12,6 +11,7 @@ import ( "github.com/gofrs/uuid" "github.com/thrasher-corp/gocryptotrader/common/convert" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) var ( diff --git a/portfolio/portfolio.go b/portfolio/portfolio.go index 965ad33c5bf..89bfe563b25 100644 --- a/portfolio/portfolio.go +++ b/portfolio/portfolio.go @@ -2,7 +2,6 @@ package portfolio import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -11,6 +10,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/log" ) From c47137c823c203a94b4e6dbd762f0245950b67de Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Tue, 20 Aug 2024 12:38:34 +1000 Subject: [PATCH 02/34] Add workflow and disallow arm and darwin usage --- .github/workflows/tests.yml | 38 ++++++++++++++++++++++++++++++++++--- encoding/json/common.go | 2 +- encoding/json/json.go | 4 +--- encoding/json/sonic.go | 6 ++---- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 979ce10a96c..487d6a45a7e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,6 +29,31 @@ jobs: goarch: amd64 psql: true skip_wrapper_tests: true + - os: ubuntu-latest-sonic + goarch: amd64 + psql: true + skip_wrapper_tests: false + sonic: true + - os: ubuntu-latest-sonic + goarch: 386 + psql: true + skip_wrapper_tests: true + sonic: true + - os: macos-latest-sonic + goarch: amd64 + psql: true + skip_wrapper_tests: true + sonic: true + - os: macos-13-sonic # beta + goarch: amd64 + psql: true + skip_wrapper_tests: true + sonic: true + - os: windows-latest-sonic + goarch: amd64 + psql: true + skip_wrapper_tests: true + sonic: true runs-on: ${{ matrix.os }} @@ -84,13 +109,20 @@ jobs: echo "CGO_ENABLED=1" >> $GITHUB_ENV shell: bash + - name: Set test flags + run: | + TEST_FLAGS="" + if [ "${{ matrix.sonic }}" = "true" ]; then + TEST_FLAGS="-tags sonic" + fi + - name: Test run: | # PGSERVICEFILE isn't supported by lib/pq and will cause a panic if set unset PGSERVICEFILE if [ "${{ matrix.goarch }}" = "386" ]; then - go test -coverprofile coverage.txt -covermode atomic ./... + go test $TEST_FLAGS -coverprofile coverage.txt -covermode atomic ./... else - go test -race -coverprofile coverage.txt -covermode atomic ./... + go test $TEST_FLAGS -race -coverprofile coverage.txt -covermode atomic ./... fi shell: bash env: @@ -169,4 +201,4 @@ jobs: cd web/ npm install npm run lint - npm run build + npm run build \ No newline at end of file diff --git a/encoding/json/common.go b/encoding/json/common.go index 55f1a51f927..c40c10bc16f 100644 --- a/encoding/json/common.go +++ b/encoding/json/common.go @@ -4,5 +4,5 @@ import "encoding/json" type ( RawMessage = json.RawMessage - UnmarshalTypeError = json.UnmarshalTypeError // Assignment as this needs associated methods + UnmarshalTypeError = json.UnmarshalTypeError ) diff --git a/encoding/json/json.go b/encoding/json/json.go index 39d53252674..c4b942b2762 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -2,9 +2,7 @@ package json -import ( - "encoding/json" -) +import "encoding/json" var ( Marshal = json.Marshal diff --git a/encoding/json/sonic.go b/encoding/json/sonic.go index 50a1990af2d..f68070acef6 100644 --- a/encoding/json/sonic.go +++ b/encoding/json/sonic.go @@ -1,10 +1,8 @@ -//go:build sonic +//go:build sonic && !(darwin || arm64) package json -import ( - "github.com/bytedance/sonic" -) +import "github.com/bytedance/sonic" var ( Marshal = sonic.ConfigStd.Marshal From 6e24f60e20c2ae76848e1f780b9c9c3e63582cb1 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Tue, 20 Aug 2024 12:57:38 +1000 Subject: [PATCH 03/34] Add basic hotswap benchmark --- encoding/json/json_benchmark_test.go | 12 ++++++++++++ encoding/json/sonic_benchmark_test.go | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 encoding/json/json_benchmark_test.go create mode 100644 encoding/json/sonic_benchmark_test.go diff --git a/encoding/json/json_benchmark_test.go b/encoding/json/json_benchmark_test.go new file mode 100644 index 00000000000..161cdd0d0af --- /dev/null +++ b/encoding/json/json_benchmark_test.go @@ -0,0 +1,12 @@ +//go:build !sonic + +package json + +import "testing" + +// 827232 1318 ns/op 816 B/op 24 allocs/op +func BenchmarkUnmarshal(b *testing.B) { + for i := 0; i < b.N; i++ { + Unmarshal([]byte(`{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}`), &map[string]interface{}{}) + } +} diff --git a/encoding/json/sonic_benchmark_test.go b/encoding/json/sonic_benchmark_test.go new file mode 100644 index 00000000000..1069ae7649a --- /dev/null +++ b/encoding/json/sonic_benchmark_test.go @@ -0,0 +1,13 @@ +//go:build sonic && !(darwin || arm64) + +package json + +import "testing" + +// BenchmarkUnmarshal-16 1900803 631.8 ns/op +// Usage: go test --tags=sonic -bench=BenchmarkUnmarshal -v +func BenchmarkUnmarshal(b *testing.B) { + for i := 0; i < b.N; i++ { + Unmarshal([]byte(`{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}`), &map[string]interface{}{}) + } +} From b70b9e7b20328b528c53c684c64953ffa7ee4ae0 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Tue, 20 Aug 2024 13:20:10 +1000 Subject: [PATCH 04/34] linter: fix --- .github/workflows/tests.yml | 5 +++++ encoding/json/common.go | 7 ++++++- encoding/json/json.go | 16 +++++++++++----- encoding/json/json_benchmark_test.go | 4 ++-- encoding/json/sonic.go | 16 +++++++++++----- encoding/json/sonic_benchmark_test.go | 4 ++-- 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 487d6a45a7e..8461dcc2952 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,22 +13,27 @@ jobs: goarch: amd64 psql: true skip_wrapper_tests: false + sonic: false - os: ubuntu-latest goarch: 386 psql: true skip_wrapper_tests: true + sonic: false - os: macos-latest goarch: amd64 psql: true skip_wrapper_tests: true + sonic: false - os: macos-13 # beta goarch: amd64 psql: true skip_wrapper_tests: true + sonic: false - os: windows-latest goarch: amd64 psql: true skip_wrapper_tests: true + sonic: false - os: ubuntu-latest-sonic goarch: amd64 psql: true diff --git a/encoding/json/common.go b/encoding/json/common.go index c40c10bc16f..5bf07d7119d 100644 --- a/encoding/json/common.go +++ b/encoding/json/common.go @@ -3,6 +3,11 @@ package json import "encoding/json" type ( - RawMessage = json.RawMessage + // RawMessage is a raw encoded JSON value. + // It implements [Marshaler] and [Unmarshaler] and can + // be used to delay JSON decoding or precompute a JSON encoding. + RawMessage = json.RawMessage + // An UnmarshalTypeError describes a JSON value that was + // not appropriate for a value of a specific Go type. UnmarshalTypeError = json.UnmarshalTypeError ) diff --git a/encoding/json/json.go b/encoding/json/json.go index c4b942b2762..1b250e089c2 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -5,10 +5,16 @@ package json import "encoding/json" var ( - Marshal = json.Marshal - Unmarshal = json.Unmarshal - NewEncoder = json.NewEncoder - NewDecoder = json.NewDecoder + // Marshal returns the JSON encoding of v. See the "encoding/json" documentation for Marshal + Marshal = json.Marshal + // Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. See the "encoding/json" documentation for Unmarshal + Unmarshal = json.Unmarshal + // NewEncoder returns a new encoder that writes to w. See the "encoding/json" documentation for NewEncoder + NewEncoder = json.NewEncoder + // NewDecoder returns a new decoder that reads from r. See the "encoding/json" documentation for NewDecoder + NewDecoder = json.NewDecoder + // MarshalIndent is like Marshal but applies Indent to format the output. See the "encoding/json" documentation for MarshalIndent MarshalIndent = json.MarshalIndent - Valid = json.Valid + // Valid reports whether data is a valid JSON encoding. See the "encoding/json" documentation for Valid + Valid = json.Valid ) diff --git a/encoding/json/json_benchmark_test.go b/encoding/json/json_benchmark_test.go index 161cdd0d0af..59d9a7c6edf 100644 --- a/encoding/json/json_benchmark_test.go +++ b/encoding/json/json_benchmark_test.go @@ -4,9 +4,9 @@ package json import "testing" -// 827232 1318 ns/op 816 B/op 24 allocs/op +// 827232 1318 ns/op 816 B/op 24 allocs/op func BenchmarkUnmarshal(b *testing.B) { for i := 0; i < b.N; i++ { - Unmarshal([]byte(`{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}`), &map[string]interface{}{}) + _ = Unmarshal([]byte(`{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}`), &map[string]interface{}{}) } } diff --git a/encoding/json/sonic.go b/encoding/json/sonic.go index f68070acef6..e6752c55402 100644 --- a/encoding/json/sonic.go +++ b/encoding/json/sonic.go @@ -5,10 +5,16 @@ package json import "github.com/bytedance/sonic" var ( - Marshal = sonic.ConfigStd.Marshal - Unmarshal = sonic.ConfigStd.Unmarshal - NewEncoder = sonic.ConfigStd.NewEncoder - NewDecoder = sonic.ConfigStd.NewDecoder + // Marshal returns the JSON encoding of v. See the "github.com/bytedance/sonic" documentation for Marshal + Marshal = sonic.ConfigStd.Marshal + // Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. See the "github.com/bytedance/sonic" documentation for Unmarshal + Unmarshal = sonic.ConfigStd.Unmarshal + // NewEncoder returns a new encoder that writes to w. See the "github.com/bytedance/sonic" documentation for NewEncoder + NewEncoder = sonic.ConfigStd.NewEncoder + // NewDecoder returns a new decoder that reads from r. See the "github.com/bytedance/sonic" documentation for NewDecoder + NewDecoder = sonic.ConfigStd.NewDecoder + // MarshalIndent is like Marshal but applies Indent to format the output. See the "github.com/bytedance/sonic" documentation for MarshalIndent MarshalIndent = sonic.ConfigStd.MarshalIndent - Valid = sonic.ConfigStd.Valid + // Valid reports whether data is a valid JSON encoding. See the "github.com/bytedance/sonic" documentation for Valid + Valid = sonic.ConfigStd.Valid ) diff --git a/encoding/json/sonic_benchmark_test.go b/encoding/json/sonic_benchmark_test.go index 1069ae7649a..5f0e9248e05 100644 --- a/encoding/json/sonic_benchmark_test.go +++ b/encoding/json/sonic_benchmark_test.go @@ -4,10 +4,10 @@ package json import "testing" -// BenchmarkUnmarshal-16 1900803 631.8 ns/op +// BenchmarkUnmarshal-16 1900803 631.8 ns/op // Usage: go test --tags=sonic -bench=BenchmarkUnmarshal -v func BenchmarkUnmarshal(b *testing.B) { for i := 0; i < b.N; i++ { - Unmarshal([]byte(`{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}`), &map[string]interface{}{}) + _ = Unmarshal([]byte(`{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}`), &map[string]interface{}{}) } } From 84dd4090d80e667405f6baedfbbab9365ecc7c91 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Tue, 20 Aug 2024 13:23:44 +1000 Subject: [PATCH 05/34] use bash --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8461dcc2952..d51a5c535ce 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -120,6 +120,7 @@ jobs: if [ "${{ matrix.sonic }}" = "true" ]; then TEST_FLAGS="-tags sonic" fi + shell: bash - name: Test run: | # PGSERVICEFILE isn't supported by lib/pq and will cause a panic if set From 711db77ffe423df7ddac621eb3b1541915cbfe8d Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Tue, 20 Aug 2024 13:36:02 +1000 Subject: [PATCH 06/34] linter: fix? --- cmd/exchange_wrapper_issues/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/exchange_wrapper_issues/main.go b/cmd/exchange_wrapper_issues/main.go index c545d98d64a..7279b5c0d0b 100644 --- a/cmd/exchange_wrapper_issues/main.go +++ b/cmd/exchange_wrapper_issues/main.go @@ -1028,7 +1028,7 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config) } func jsonifyInterface(params []interface{}) json.RawMessage { - response, _ := json.MarshalIndent(params, "", " ") //nolint:errchkjson // TODO: ignore this for now + response, _ := json.MarshalIndent(params, "", " ") return response } From 223f786b9b6800cec41d5460d606408f7719dbf0 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Tue, 20 Aug 2024 15:26:13 +1000 Subject: [PATCH 07/34] Fix whoopsie, add to make file, also add mention in features list. --- .github/workflows/tests.yml | 10 +++++----- Makefile | 4 ++++ README.md | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d51a5c535ce..66ec70e20e0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,27 +34,27 @@ jobs: psql: true skip_wrapper_tests: true sonic: false - - os: ubuntu-latest-sonic + - os: ubuntu-latest goarch: amd64 psql: true skip_wrapper_tests: false sonic: true - - os: ubuntu-latest-sonic + - os: ubuntu-latest goarch: 386 psql: true skip_wrapper_tests: true sonic: true - - os: macos-latest-sonic + - os: macos-latest goarch: amd64 psql: true skip_wrapper_tests: true sonic: true - - os: macos-13-sonic # beta + - os: macos-13 # beta goarch: amd64 psql: true skip_wrapper_tests: true sonic: true - - os: windows-latest-sonic + - os: windows-latest goarch: amd64 psql: true skip_wrapper_tests: true diff --git a/Makefile b/Makefile index 7b87e8025ef..4537cab3954 100644 --- a/Makefile +++ b/Makefile @@ -78,3 +78,7 @@ endef check-jq: @printf "Checking if jq is installed... " @command -v jq >/dev/null 2>&1 && { printf "OK\n"; } || { printf "FAILED. Please install jq to proceed.\n"; exit 1; } + +.PHONY: sonic +sonic: + go build -tags=sonic ./... \ No newline at end of file diff --git a/README.md b/README.md index be393b5a672..6bac81f9227 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ However, we welcome pull requests for any exchange which does not match this cri + WebGUI (discontinued). + Exchange HTTP mock testing. See [mock](/exchanges/mock/README.md). + Exchange multichain deposits and withdrawals for specific exchanges. See [multichain transfer support](/docs/MULTICHAIN_TRANSFER_SUPPORT.md). ++ **Sonic JSON Integration**: Swap between the default Go 'encoding/json' package and the sonic library using go build tags for optimized JSON handling `-tags=sonic` or by using the make file `make sonic` ## Planned Features From 6b6fb5ec3295a440dbfc29fddb930626009bac84 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Tue, 12 Nov 2024 10:04:01 +1100 Subject: [PATCH 08/34] test enforcement --- .golangci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index b59ae9635b3..36cb3717973 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -25,7 +25,7 @@ linters: - copyloopvar # - cyclop - decorder -# - depguard + - depguard - dogsled # - dupl - dupword @@ -141,6 +141,12 @@ linters-settings: - float-compare # We deliberately use Equal over Len to avoid spamming the contents of large Slices - len + depguard: + list-type: blacklist + packages: + - encoding/json + packages-with-error-message: + enconding/json: "Please use the custom JSON package github.com/thrasher-corp/gocryptotrader/encoding/json instead of encoding/json to allow sonic/json switching." issues: max-issues-per-linter: 0 From ac47cc6bb73794f7faf7de8b06f5d41a441df96a Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Tue, 12 Nov 2024 10:19:02 +1100 Subject: [PATCH 09/34] actually read documentation see if this works --- .golangci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 36cb3717973..ae7e50862e3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -117,6 +117,17 @@ linters: # - zerologlint linters-settings: + depguard: + rules: + prevent_json_package_use: + list-mode: lax # allow unless explicitely denied + files: + - $all + allow: + - github.com/thrasher-corp/gocryptotrader/encoding/json + deny: + - pkg: encoding/json + desc: "Please use the custom JSON package github.com/thrasher-corp/gocryptotrader/encoding/json instead of encoding/json to allow sonic/json switching." govet: enable: - shadow @@ -141,13 +152,6 @@ linters-settings: - float-compare # We deliberately use Equal over Len to avoid spamming the contents of large Slices - len - depguard: - list-type: blacklist - packages: - - encoding/json - packages-with-error-message: - enconding/json: "Please use the custom JSON package github.com/thrasher-corp/gocryptotrader/encoding/json instead of encoding/json to allow sonic/json switching." - issues: max-issues-per-linter: 0 max-same-issues: 0 From 135e2b6122dcc5ab6bd5909f9bf3a28c961e1ae2 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Tue, 12 Nov 2024 10:27:02 +1100 Subject: [PATCH 10/34] linter: fix --- encoding/json/common.go | 2 +- encoding/json/json.go | 2 +- exchanges/kraken/mock_ws_test.go | 2 +- types/time_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/encoding/json/common.go b/encoding/json/common.go index 5bf07d7119d..33c4e22bc65 100644 --- a/encoding/json/common.go +++ b/encoding/json/common.go @@ -1,6 +1,6 @@ package json -import "encoding/json" +import "encoding/json" //nolint:depguard // This is a wrapper package type ( // RawMessage is a raw encoded JSON value. diff --git a/encoding/json/json.go b/encoding/json/json.go index 1b250e089c2..2511c9357ad 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -2,7 +2,7 @@ package json -import "encoding/json" +import "encoding/json" //nolint:depguard // This is a wrapper package var ( // Marshal returns the JSON encoding of v. See the "encoding/json" documentation for Marshal diff --git a/exchanges/kraken/mock_ws_test.go b/exchanges/kraken/mock_ws_test.go index 09df7b747df..80e04cdb91d 100644 --- a/exchanges/kraken/mock_ws_test.go +++ b/exchanges/kraken/mock_ws_test.go @@ -1,7 +1,6 @@ package kraken import ( - "encoding/json" "fmt" "strings" "testing" @@ -9,6 +8,7 @@ import ( "github.com/buger/jsonparser" "github.com/gorilla/websocket" "github.com/stretchr/testify/assert" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func mockWsServer(tb testing.TB, msg []byte, w *websocket.Conn) error { diff --git a/types/time_test.go b/types/time_test.go index 97e529294d4..f024c613a92 100644 --- a/types/time_test.go +++ b/types/time_test.go @@ -1,13 +1,13 @@ package types import ( - "encoding/json" "strconv" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) func TestUnmarshalJSON(t *testing.T) { From 1ca8eaa1510fe989b634ae18f1a1f4134a2b7ce0 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 9 Jan 2025 10:10:54 +1100 Subject: [PATCH 11/34] linter: fix --- config/versions/v1.go | 2 +- exchanges/gateio/gateio_websocket_request_spot.go | 2 +- exchanges/gateio/gateio_websocket_request_types.go | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/config/versions/v1.go b/config/versions/v1.go index 378d6c35c9f..5d3dc165f22 100644 --- a/config/versions/v1.go +++ b/config/versions/v1.go @@ -2,11 +2,11 @@ package versions import ( "context" - "encoding/json" "github.com/buger/jsonparser" v0 "github.com/thrasher-corp/gocryptotrader/config/versions/v0" v1 "github.com/thrasher-corp/gocryptotrader/config/versions/v1" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // Version1 is an ExchangeVersion to upgrade currency pair format for exchanges diff --git a/exchanges/gateio/gateio_websocket_request_spot.go b/exchanges/gateio/gateio_websocket_request_spot.go index 25ac1ea1689..4069c3a2bfb 100644 --- a/exchanges/gateio/gateio_websocket_request_spot.go +++ b/exchanges/gateio/gateio_websocket_request_spot.go @@ -2,7 +2,6 @@ package gateio import ( "context" - "encoding/json" "errors" "fmt" "strconv" @@ -11,6 +10,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/exchanges/request" diff --git a/exchanges/gateio/gateio_websocket_request_types.go b/exchanges/gateio/gateio_websocket_request_types.go index 165eea41cba..c4bc766f576 100644 --- a/exchanges/gateio/gateio_websocket_request_types.go +++ b/exchanges/gateio/gateio_websocket_request_types.go @@ -1,9 +1,8 @@ package gateio import ( - "encoding/json" - "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/types" ) From ab5fd0119acd1ab43977231f5d362ebb945e77c9 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Fri, 10 Jan 2025 12:45:34 +1100 Subject: [PATCH 12/34] sonic: bump tagged version --- go.mod | 9 ++++----- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 85e113e4b59..d93bcd1d8f1 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.23.0 require ( github.com/Masterminds/sprig/v3 v3.3.0 github.com/buger/jsonparser v1.1.1 - github.com/bytedance/sonic v1.12.1 + github.com/bytedance/sonic v1.12.7 github.com/d5/tengo/v2 v2.17.0 github.com/gofrs/uuid v4.4.0+incompatible github.com/gorilla/mux v1.8.1 @@ -40,9 +40,8 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.3.0 // indirect github.com/boombuler/barcode v1.0.1 // indirect - github.com/bytedance/sonic/loader v0.2.0 // indirect + github.com/bytedance/sonic/loader v0.2.2 // indirect github.com/cloudwego/base64x v0.1.4 // indirect - github.com/cloudwego/iasm v0.2.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/friendsofgo/errors v0.9.2 // indirect @@ -50,7 +49,7 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/huandu/xstrings v1.5.0 // indirect - github.com/klauspost/cpuid/v2 v2.0.9 // indirect + github.com/klauspost/cpuid/v2 v2.2.9 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -71,7 +70,7 @@ require ( github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect + golang.org/x/arch v0.13.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/sys v0.29.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect diff --git a/go.sum b/go.sum index aaf7b013f49..5ddfd862fe0 100644 --- a/go.sum +++ b/go.sum @@ -28,17 +28,16 @@ github.com/boombuler/barcode v1.0.1 h1:NDBbPmhS+EqABEs5Kg3n/5ZNjy73Pz7SIV+KCeqyX github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/bytedance/sonic v1.12.1 h1:jWl5Qz1fy7X1ioY74WqO0KjAMtAGQs4sYnjiEBiyX24= -github.com/bytedance/sonic v1.12.1/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic v1.12.7 h1:CQU8pxOy9HToxhndH0Kx/S1qU/CuS9GnKYrGioDcU1Q= +github.com/bytedance/sonic v1.12.7/go.mod h1:tnbal4mxOMju17EGfknm2XyYcpyCnIROYOEYuemj13I= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= -github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= -github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/bytedance/sonic/loader v0.2.2 h1:jxAJuN9fOot/cyz5Q6dUuMJF5OqQ6+5GfA8FjjQ0R4o= +github.com/bytedance/sonic/loader v0.2.2/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= @@ -130,8 +129,9 @@ github.com/kat-co/vala v0.0.0-20170210184112-42e1d8b61f12/go.mod h1:u9MdXq/QageO github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY= +github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -290,8 +290,8 @@ go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.13.0 h1:KCkqVVV1kGg0X87TFysjCJ8MxtZEIU4Ja/yXGeoECdA= +golang.org/x/arch v0.13.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= From 1697977b1ddaba0ea9a78cee01c156fcf607e7ec Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Fri, 10 Jan 2025 12:49:29 +1100 Subject: [PATCH 13/34] encoding/json: drop build tag arch and os filters --- encoding/json/sonic.go | 2 +- encoding/json/sonic_benchmark_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/encoding/json/sonic.go b/encoding/json/sonic.go index e6752c55402..eae2a159792 100644 --- a/encoding/json/sonic.go +++ b/encoding/json/sonic.go @@ -1,4 +1,4 @@ -//go:build sonic && !(darwin || arm64) +//go:build sonic package json diff --git a/encoding/json/sonic_benchmark_test.go b/encoding/json/sonic_benchmark_test.go index 5f0e9248e05..99061a79987 100644 --- a/encoding/json/sonic_benchmark_test.go +++ b/encoding/json/sonic_benchmark_test.go @@ -1,4 +1,4 @@ -//go:build sonic && !(darwin || arm64) +//go:build sonic package json From 3905b625d959af4a2784355f90f72630a4d041ed Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Fri, 10 Jan 2025 12:57:47 +1100 Subject: [PATCH 14/34] encoding/json: consolidate tests --- encoding/json/benchmark_test.go | 12 ++++++++++++ encoding/json/json_benchmark_test.go | 12 ------------ encoding/json/sonic_benchmark_test.go | 13 ------------- 3 files changed, 12 insertions(+), 25 deletions(-) create mode 100644 encoding/json/benchmark_test.go delete mode 100644 encoding/json/json_benchmark_test.go delete mode 100644 encoding/json/sonic_benchmark_test.go diff --git a/encoding/json/benchmark_test.go b/encoding/json/benchmark_test.go new file mode 100644 index 00000000000..91898556bd4 --- /dev/null +++ b/encoding/json/benchmark_test.go @@ -0,0 +1,12 @@ +package json + +import "testing" + +// BenchmarkUnmarshal-16 838503 1282 ns/op 816 B/op 24 allocs/op (encoding/json) +// BenchmarkUnmarshal-16 1859184 653.3 ns/op 900 B/op 18 allocs/op (bytedance/sonic) Usage: go test --tags=sonic -bench=BenchmarkUnmarshal -v +func BenchmarkUnmarshal(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + _ = Unmarshal([]byte(`{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}`), &map[string]interface{}{}) + } +} diff --git a/encoding/json/json_benchmark_test.go b/encoding/json/json_benchmark_test.go deleted file mode 100644 index 59d9a7c6edf..00000000000 --- a/encoding/json/json_benchmark_test.go +++ /dev/null @@ -1,12 +0,0 @@ -//go:build !sonic - -package json - -import "testing" - -// 827232 1318 ns/op 816 B/op 24 allocs/op -func BenchmarkUnmarshal(b *testing.B) { - for i := 0; i < b.N; i++ { - _ = Unmarshal([]byte(`{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}`), &map[string]interface{}{}) - } -} diff --git a/encoding/json/sonic_benchmark_test.go b/encoding/json/sonic_benchmark_test.go deleted file mode 100644 index 99061a79987..00000000000 --- a/encoding/json/sonic_benchmark_test.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build sonic - -package json - -import "testing" - -// BenchmarkUnmarshal-16 1900803 631.8 ns/op -// Usage: go test --tags=sonic -bench=BenchmarkUnmarshal -v -func BenchmarkUnmarshal(b *testing.B) { - for i := 0; i < b.N; i++ { - _ = Unmarshal([]byte(`{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}`), &map[string]interface{}{}) - } -} From 1c9f9c2ee6adcd8c0c79932526602fe189b4979e Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Fri, 10 Jan 2025 13:19:07 +1100 Subject: [PATCH 15/34] encoding/json: log build tag usage --- encoding/json/json.go | 3 +++ encoding/json/sonic.go | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/encoding/json/json.go b/encoding/json/json.go index 2511c9357ad..134873acb51 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -4,6 +4,9 @@ package json import "encoding/json" //nolint:depguard // This is a wrapper package +// Version is a constant string that represents the current JSON implementation package +const Version = "encoding/json" + var ( // Marshal returns the JSON encoding of v. See the "encoding/json" documentation for Marshal Marshal = json.Marshal diff --git a/encoding/json/sonic.go b/encoding/json/sonic.go index eae2a159792..2f780f7afa1 100644 --- a/encoding/json/sonic.go +++ b/encoding/json/sonic.go @@ -2,7 +2,14 @@ package json -import "github.com/bytedance/sonic" +import ( + "log" + + "github.com/bytedance/sonic" +) + +// Version is a constant string that represents the current JSON implementation package +const Version = "bytedance/sonic" var ( // Marshal returns the JSON encoding of v. See the "github.com/bytedance/sonic" documentation for Marshal @@ -18,3 +25,7 @@ var ( // Valid reports whether data is a valid JSON encoding. See the "github.com/bytedance/sonic" documentation for Valid Valid = sonic.ConfigStd.Valid ) + +func init() { + log.Printf("Using %s for JSON encoding\n", Version) +} From 9cffc8f7a900b6186d2041412e1d4eef0099947e Mon Sep 17 00:00:00 2001 From: shazbert Date: Tue, 14 Jan 2025 10:28:50 +1100 Subject: [PATCH 16/34] rm superfluous builds --- .github/workflows/tests.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 78d378bec08..b126e2f6f2f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -39,26 +39,6 @@ jobs: psql: true skip_wrapper_tests: false sonic: true - - os: ubuntu-latest - goarch: 386 - psql: true - skip_wrapper_tests: true - sonic: true - - os: macos-latest - goarch: amd64 - psql: true - skip_wrapper_tests: true - sonic: true - - os: macos-13 # beta - goarch: amd64 - psql: true - skip_wrapper_tests: true - sonic: true - - os: windows-latest - goarch: amd64 - psql: true - skip_wrapper_tests: true - sonic: true runs-on: ${{ matrix.os }} From 1b15e4cede3ebda573ba7a00ad1f20d1bc57d918 Mon Sep 17 00:00:00 2001 From: shazbert Date: Tue, 28 Jan 2025 12:14:34 +1100 Subject: [PATCH 17/34] glorious/nits: add template change and regen docs --- LICENSE | 2 +- README.md | 12 +-- .../root_templates/root_readme.tmpl | 1 + engine/currency_state_manager.md | 74 +++++++++---------- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/LICENSE b/LICENSE index 3abf50b2f4f..299e2c79afe 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2024 The GoCryptoTrader Developers +Copyright (c) 2014-2025 The GoCryptoTrader Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index ed450ad98a1..f3d243de629 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ However, we welcome pull requests for any exchange which does not match this cri + WebGUI (discontinued). + Exchange HTTP mock testing. See [mock](/exchanges/mock/README.md). + Exchange multichain deposits and withdrawals for specific exchanges. See [multichain transfer support](/docs/MULTICHAIN_TRANSFER_SUPPORT.md). -+ **Sonic JSON Integration**: Swap between the default Go 'encoding/json' package and the sonic library using go build tags for optimized JSON handling `-tags=sonic` or by using the make file `make sonic` ++ Sonic JSON Integration. Swap between the default Go 'encoding/json' package and the sonic library using go build tags for optimized JSON handling `-tags=sonic` or by using the make file `make sonic` ## Development Tracking @@ -149,15 +149,15 @@ Binaries will be published once the codebase reaches a stable condition. |User|Contribution Amount| |--|--| -| [thrasher-](https://github.com/thrasher-) | 703 | -| [shazbert](https://github.com/shazbert) | 355 | -| [dependabot[bot]](https://github.com/apps/dependabot) | 331 | +| [thrasher-](https://github.com/thrasher-) | 704 | +| [shazbert](https://github.com/shazbert) | 356 | +| [dependabot[bot]](https://github.com/apps/dependabot) | 344 | | [gloriousCode](https://github.com/gloriousCode) | 236 | -| [gbjk](https://github.com/gbjk) | 107 | +| [gbjk](https://github.com/gbjk) | 111 | | [dependabot-preview[bot]](https://github.com/apps/dependabot-preview) | 88 | | [xtda](https://github.com/xtda) | 47 | | [lrascao](https://github.com/lrascao) | 27 | -| [Beadko](https://github.com/Beadko) | 17 | +| [Beadko](https://github.com/Beadko) | 18 | | [Rots](https://github.com/Rots) | 15 | | [vazha](https://github.com/vazha) | 15 | | [ydm](https://github.com/ydm) | 15 | diff --git a/cmd/documentation/root_templates/root_readme.tmpl b/cmd/documentation/root_templates/root_readme.tmpl index 276fb7aa2b8..fc9458c60c8 100644 --- a/cmd/documentation/root_templates/root_readme.tmpl +++ b/cmd/documentation/root_templates/root_readme.tmpl @@ -78,6 +78,7 @@ However, we welcome pull requests for any exchange which does not match this cri + WebGUI (discontinued). + Exchange HTTP mock testing. See [mock](/exchanges/mock/README.md). + Exchange multichain deposits and withdrawals for specific exchanges. See [multichain transfer support](/docs/MULTICHAIN_TRANSFER_SUPPORT.md). ++ Sonic JSON Integration. Swap between the default Go 'encoding/json' package and the sonic library using go build tags for optimized JSON handling `-tags=sonic` or by using the make file `make sonic` ## Development Tracking diff --git a/engine/currency_state_manager.md b/engine/currency_state_manager.md index cb6a44d9a57..5e938e72fab 100644 --- a/engine/currency_state_manager.md +++ b/engine/currency_state_manager.md @@ -1,22 +1,22 @@ -# GoCryptoTrader package Currency state manager - - - - -[![Build Status](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml) -[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-corp/gocryptotrader/blob/master/LICENSE) -[![GoDoc](https://godoc.org/github.com/thrasher-corp/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-corp/gocryptotrader/engine/currency_state_manager) -[![Coverage Status](https://codecov.io/gh/thrasher-corp/gocryptotrader/graph/badge.svg?token=41784B23TS)](https://codecov.io/gh/thrasher-corp/gocryptotrader) -[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-corp/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-corp/gocryptotrader) - - -This currency_state_manager package is part of the GoCryptoTrader codebase. - -## This is still in active development - -You can track ideas, planned features and what's in progress on our [GoCryptoTrader Kanban board](https://github.com/orgs/thrasher-corp/projects/3). - -Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://join.slack.com/t/gocryptotrader/shared_invite/enQtNTQ5NDAxMjA2Mjc5LTc5ZDE1ZTNiOGM3ZGMyMmY1NTAxYWZhODE0MWM5N2JlZDk1NDU0YTViYzk4NTk3OTRiMDQzNGQ1YTc4YmRlMTk) +# GoCryptoTrader package Currency state manager + + + + +[![Build Status](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml) +[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-corp/gocryptotrader/blob/master/LICENSE) +[![GoDoc](https://godoc.org/github.com/thrasher-corp/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-corp/gocryptotrader/engine/currency_state_manager) +[![Coverage Status](https://codecov.io/gh/thrasher-corp/gocryptotrader/graph/badge.svg?token=41784B23TS)](https://codecov.io/gh/thrasher-corp/gocryptotrader) +[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-corp/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-corp/gocryptotrader) + + +This currency_state_manager package is part of the GoCryptoTrader codebase. + +## This is still in active development + +You can track ideas, planned features and what's in progress on our [GoCryptoTrader Kanban board](https://github.com/orgs/thrasher-corp/projects/3). + +Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://join.slack.com/t/gocryptotrader/shared_invite/enQtNTQ5NDAxMjA2Mjc5LTc5ZDE1ZTNiOGM3ZGMyMmY1NTAxYWZhODE0MWM5N2JlZDk1NDU0YTViYzk4NTk3OTRiMDQzNGQ1YTc4YmRlMTk) ## Current Features for Currency state manager + The state manager keeps currency states up to date, which include: @@ -27,22 +27,22 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader + This allows for an internal state check to compliment internal and external strategies. - -## Contribution - -Please feel free to submit any pull requests or suggest any desired features to be added. - -When submitting a PR, please abide by our coding guidelines: - -+ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). -+ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. -+ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/doc/coding_style.md). -+ Pull requests need to be based on and opened against the `master` branch. - -## Donations - - - -If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to: - + +## Contribution + +Please feel free to submit any pull requests or suggest any desired features to be added. + +When submitting a PR, please abide by our coding guidelines: + ++ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). ++ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. ++ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/doc/coding_style.md). ++ Pull requests need to be based on and opened against the `master` branch. + +## Donations + + + +If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to: + ***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc*** From a7ac15d84c6397471da982d012049964f5dced1d Mon Sep 17 00:00:00 2001 From: shazbert Date: Tue, 28 Jan 2025 12:27:51 +1100 Subject: [PATCH 18/34] glorious/nits: update commentary on nolint directive --- encoding/json/common.go | 2 +- encoding/json/json.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/encoding/json/common.go b/encoding/json/common.go index 33c4e22bc65..d12831007f0 100644 --- a/encoding/json/common.go +++ b/encoding/json/common.go @@ -1,6 +1,6 @@ package json -import "encoding/json" //nolint:depguard // This is a wrapper package +import "encoding/json" //nolint:depguard // This is a wrapper package for encoding/json. All uses of JSON throughout the application should refer to this package in all builds. type ( // RawMessage is a raw encoded JSON value. diff --git a/encoding/json/json.go b/encoding/json/json.go index 134873acb51..d026bc9c94f 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -2,7 +2,7 @@ package json -import "encoding/json" //nolint:depguard // This is a wrapper package +import "encoding/json" //nolint:depguard // This is a wrapper package for encoding/json. It serves as the default JSON package for GCT (GoCryptoTrader). All uses of JSON throughout the application should refer to this package with the default build. // Version is a constant string that represents the current JSON implementation package const Version = "encoding/json" From f23f3c3d672dfd44fbb47fbb7ddc598f5a7a53df Mon Sep 17 00:00:00 2001 From: shazbert Date: Tue, 28 Jan 2025 12:38:28 +1100 Subject: [PATCH 19/34] glorious/nits: rm init func and log results in main.go --- encoding/json/sonic.go | 6 ------ main.go | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/encoding/json/sonic.go b/encoding/json/sonic.go index 2f780f7afa1..0abd3b9ff2d 100644 --- a/encoding/json/sonic.go +++ b/encoding/json/sonic.go @@ -3,8 +3,6 @@ package json import ( - "log" - "github.com/bytedance/sonic" ) @@ -25,7 +23,3 @@ var ( // Valid reports whether data is a valid JSON encoding. See the "github.com/bytedance/sonic" documentation for Valid Valid = sonic.ConfigStd.Valid ) - -func init() { - log.Printf("Using %s for JSON encoding\n", Version) -} diff --git a/main.go b/main.go index 86575a81bc4..74d3cafeda1 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/dispatch" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/engine" "github.com/thrasher-corp/gocryptotrader/exchanges/alert" "github.com/thrasher-corp/gocryptotrader/exchanges/request" @@ -140,6 +141,8 @@ func main() { gctscript.Setup() + gctlog.Infof(gctlog.Global, "JSON encoding is set to package `%s`", json.Version) + engine.Bot.Settings.PrintLoadedSettings() if err = engine.Bot.Start(); err != nil { From fba53166aa7ea916672d2956f9829c4b8d6b93b7 Mon Sep 17 00:00:00 2001 From: shazbert Date: Tue, 28 Jan 2025 12:52:11 +1100 Subject: [PATCH 20/34] Test to actually pull flag in --- .github/workflows/tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b126e2f6f2f..b7ce17e35a5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -96,9 +96,8 @@ jobs: - name: Set test flags run: | - TEST_FLAGS="" if [ "${{ matrix.sonic }}" = "true" ]; then - TEST_FLAGS="-tags sonic" + echo "TEST_FLAGS=-tags sonic" >> $GITHUB_ENV fi shell: bash From c936252f9c2c025a345ea588bdc7dba1b84e657b Mon Sep 17 00:00:00 2001 From: shazbert Date: Tue, 11 Feb 2025 11:54:25 +1100 Subject: [PATCH 21/34] linter: fix --- config/versions/v3.go | 2 +- exchanges/okx/okx_business_websocket.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/versions/v3.go b/config/versions/v3.go index b7773c9a4b0..a8d52ce5462 100644 --- a/config/versions/v3.go +++ b/config/versions/v3.go @@ -2,10 +2,10 @@ package versions import ( "context" - "encoding/json" "time" "github.com/buger/jsonparser" + "github.com/thrasher-corp/gocryptotrader/encoding/json" ) // Version3 is an ExchangeVersion to remove the publishPeriod from the exchange's orderbook config diff --git a/exchanges/okx/okx_business_websocket.go b/exchanges/okx/okx_business_websocket.go index 83ca7e9c1a0..5056c40d475 100644 --- a/exchanges/okx/okx_business_websocket.go +++ b/exchanges/okx/okx_business_websocket.go @@ -2,7 +2,6 @@ package okx import ( "context" - "encoding/json" "fmt" "net/http" "strconv" @@ -12,6 +11,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/request" "github.com/thrasher-corp/gocryptotrader/exchanges/stream" From a843b585c9feedc21450ef3277cfe080b3b0dedf Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Wed, 12 Feb 2025 11:19:32 +1100 Subject: [PATCH 22/34] thrasher: nits --- exchanges/kraken/kraken_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exchanges/kraken/kraken_test.go b/exchanges/kraken/kraken_test.go index 1d39fc7fc99..234ac536347 100644 --- a/exchanges/kraken/kraken_test.go +++ b/exchanges/kraken/kraken_test.go @@ -1680,7 +1680,7 @@ func TestErrorResponse(t *testing.T) { func TestGetFuturesErr(t *testing.T) { t.Parallel() - assert.ErrorContains(t, getFuturesErr(json.RawMessage(`unparsable rubbish`)), "invalid character", "Bad JSON should error correctly") + assert.ErrorContains(t, getFuturesErr(json.RawMessage(`unparsable rubbish`)), "invalid char", "Bad JSON should error correctly") assert.NoError(t, getFuturesErr(json.RawMessage(`{"candles":[]}`)), "JSON with no Result should not error") assert.NoError(t, getFuturesErr(json.RawMessage(`{"Result":"4 goats"}`)), "JSON with non-error Result should not error") assert.ErrorIs(t, getFuturesErr(json.RawMessage(`{"Result":"error"}`)), common.ErrUnknownError, "JSON with error Result should error correctly") From 09bac6c0cdef4a5434d80e435b0c0ee0cdf82351 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 13 Feb 2025 14:18:25 +1100 Subject: [PATCH 23/34] gk: nits 4 goflags goooooooooo! --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b7ce17e35a5..1f7b61a5cdd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -94,10 +94,10 @@ jobs: echo "CGO_ENABLED=1" >> $GITHUB_ENV shell: bash - - name: Set test flags + - name: Set GOFLAGS run: | if [ "${{ matrix.sonic }}" = "true" ]; then - echo "TEST_FLAGS=-tags sonic" >> $GITHUB_ENV + echo "GOFLAGS=${GOFLAGS} -tags=sonic" >> $GITHUB_ENV fi shell: bash @@ -105,9 +105,9 @@ jobs: run: | # PGSERVICEFILE isn't supported by lib/pq and will cause a panic if set unset PGSERVICEFILE if [ "${{ matrix.goarch }}" = "386" ]; then - go test $TEST_FLAGS -coverprofile coverage.txt -covermode atomic ./... + go test -coverprofile coverage.txt -covermode atomic ./... else - go test $TEST_FLAGS -race -coverprofile coverage.txt -covermode atomic ./... + go test -race -coverprofile coverage.txt -covermode atomic ./... fi shell: bash env: From a9ce5aa821ccc3e2e76ccf7d317b4b0d8cd70e3c Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Fri, 14 Feb 2025 15:56:48 +1100 Subject: [PATCH 24/34] gk: nits rn --- encoding/json/json.go | 4 ++-- encoding/json/sonic.go | 4 ++-- main.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/encoding/json/json.go b/encoding/json/json.go index d026bc9c94f..09431d52e88 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -4,8 +4,8 @@ package json import "encoding/json" //nolint:depguard // This is a wrapper package for encoding/json. It serves as the default JSON package for GCT (GoCryptoTrader). All uses of JSON throughout the application should refer to this package with the default build. -// Version is a constant string that represents the current JSON implementation package -const Version = "encoding/json" +// Implementation is a constant string that represents the current JSON implementation package +const Implementation = "encoding/json" var ( // Marshal returns the JSON encoding of v. See the "encoding/json" documentation for Marshal diff --git a/encoding/json/sonic.go b/encoding/json/sonic.go index 0abd3b9ff2d..3469c024421 100644 --- a/encoding/json/sonic.go +++ b/encoding/json/sonic.go @@ -6,8 +6,8 @@ import ( "github.com/bytedance/sonic" ) -// Version is a constant string that represents the current JSON implementation package -const Version = "bytedance/sonic" +// Implementation is a constant string that represents the current JSON implementation package +const Implementation = "bytedance/sonic" var ( // Marshal returns the JSON encoding of v. See the "github.com/bytedance/sonic" documentation for Marshal diff --git a/main.go b/main.go index 74d3cafeda1..1811dee4b42 100644 --- a/main.go +++ b/main.go @@ -141,7 +141,7 @@ func main() { gctscript.Setup() - gctlog.Infof(gctlog.Global, "JSON encoding is set to package `%s`", json.Version) + gctlog.Infof(gctlog.Global, "JSON encoding is set to package `%s`", json.Implementation) engine.Bot.Settings.PrintLoadedSettings() From 9fff614b0c7735e9d8ea925506b986cd6200f9b4 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 20 Feb 2025 10:16:29 +1100 Subject: [PATCH 25/34] make sonic default json implementation --- .github/workflows/tests.yml | 16 ++-- Makefile | 6 +- README.md | 6 +- .../root_templates/root_readme.tmpl | 2 +- encoding/json/json.go | 4 +- encoding/json/sonic.go | 2 +- engine/currency_state_manager.md | 74 +++++++++---------- 7 files changed, 55 insertions(+), 55 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1f7b61a5cdd..3926bd9d67d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,32 +13,32 @@ jobs: goarch: amd64 psql: true skip_wrapper_tests: false - sonic: false + sonic: true - os: ubuntu-latest goarch: 386 psql: true skip_wrapper_tests: true - sonic: false + sonic: true - os: macos-latest goarch: amd64 psql: true skip_wrapper_tests: true - sonic: false + sonic: true - os: macos-13 # beta goarch: amd64 psql: true skip_wrapper_tests: true - sonic: false + sonic: true - os: windows-latest goarch: amd64 psql: true skip_wrapper_tests: true - sonic: false + sonic: true - os: ubuntu-latest goarch: amd64 psql: true skip_wrapper_tests: false - sonic: true + sonic: false runs-on: ${{ matrix.os }} @@ -96,8 +96,8 @@ jobs: - name: Set GOFLAGS run: | - if [ "${{ matrix.sonic }}" = "true" ]; then - echo "GOFLAGS=${GOFLAGS} -tags=sonic" >> $GITHUB_ENV + if [ "${{ matrix.sonic }}" = "false" ]; then + echo "GOFLAGS=${GOFLAGS} -tags=sonic_off" >> $GITHUB_ENV fi shell: bash diff --git a/Makefile b/Makefile index 4537cab3954..49791ee028b 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,6 @@ check-jq: @printf "Checking if jq is installed... " @command -v jq >/dev/null 2>&1 && { printf "OK\n"; } || { printf "FAILED. Please install jq to proceed.\n"; exit 1; } -.PHONY: sonic -sonic: - go build -tags=sonic ./... \ No newline at end of file +.PHONY: no_sonic +no_sonic: + go build -tags=sonic_off ./... \ No newline at end of file diff --git a/README.md b/README.md index ff9fd3894ce..e48a6cc14d8 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ However, we welcome pull requests for any exchange which does not match this cri + WebGUI (discontinued). + Exchange HTTP mock testing. See [mock](/exchanges/mock/README.md). + Exchange multichain deposits and withdrawals for specific exchanges. See [multichain transfer support](/docs/MULTICHAIN_TRANSFER_SUPPORT.md). -+ Sonic JSON Integration. Swap between the default Go 'encoding/json' package and the sonic library using go build tags for optimized JSON handling `-tags=sonic` or by using the make file `make sonic` ++ Sonic JSON Integration. Revert back to the default Go 'encoding/json' package from the sonic library using go build tags `-tags=sonic_off` or by using the make file `make no_sonic` ## Development Tracking @@ -150,10 +150,10 @@ Binaries will be published once the codebase reaches a stable condition. |User|Contribution Amount| |--|--| | [thrasher-](https://github.com/thrasher-) | 704 | -| [shazbert](https://github.com/shazbert) | 358 | +| [shazbert](https://github.com/shazbert) | 359 | | [dependabot[bot]](https://github.com/apps/dependabot) | 351 | | [gloriousCode](https://github.com/gloriousCode) | 236 | -| [gbjk](https://github.com/gbjk) | 113 | +| [gbjk](https://github.com/gbjk) | 115 | | [dependabot-preview[bot]](https://github.com/apps/dependabot-preview) | 88 | | [xtda](https://github.com/xtda) | 47 | | [lrascao](https://github.com/lrascao) | 27 | diff --git a/cmd/documentation/root_templates/root_readme.tmpl b/cmd/documentation/root_templates/root_readme.tmpl index fc9458c60c8..f2e93805f93 100644 --- a/cmd/documentation/root_templates/root_readme.tmpl +++ b/cmd/documentation/root_templates/root_readme.tmpl @@ -78,7 +78,7 @@ However, we welcome pull requests for any exchange which does not match this cri + WebGUI (discontinued). + Exchange HTTP mock testing. See [mock](/exchanges/mock/README.md). + Exchange multichain deposits and withdrawals for specific exchanges. See [multichain transfer support](/docs/MULTICHAIN_TRANSFER_SUPPORT.md). -+ Sonic JSON Integration. Swap between the default Go 'encoding/json' package and the sonic library using go build tags for optimized JSON handling `-tags=sonic` or by using the make file `make sonic` ++ Sonic JSON Integration. Revert back to the default Go 'encoding/json' package from the sonic library using go build tags `-tags=sonic_off` or by using the make file `make no_sonic` ## Development Tracking diff --git a/encoding/json/json.go b/encoding/json/json.go index 09431d52e88..6631b46e14c 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -1,8 +1,8 @@ -//go:build !sonic +//go:build sonic_off package json -import "encoding/json" //nolint:depguard // This is a wrapper package for encoding/json. It serves as the default JSON package for GCT (GoCryptoTrader). All uses of JSON throughout the application should refer to this package with the default build. +import "encoding/json" //nolint:depguard // This is a wrapper package for encoding/json. All uses of JSON throughout the application should refer to this when sonic_off build tag is used. // Implementation is a constant string that represents the current JSON implementation package const Implementation = "encoding/json" diff --git a/encoding/json/sonic.go b/encoding/json/sonic.go index 3469c024421..5e5a913210b 100644 --- a/encoding/json/sonic.go +++ b/encoding/json/sonic.go @@ -1,4 +1,4 @@ -//go:build sonic +//go:build !sonic_off package json diff --git a/engine/currency_state_manager.md b/engine/currency_state_manager.md index 5e938e72fab..cb6a44d9a57 100644 --- a/engine/currency_state_manager.md +++ b/engine/currency_state_manager.md @@ -1,22 +1,22 @@ -# GoCryptoTrader package Currency state manager - - - - -[![Build Status](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml) -[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-corp/gocryptotrader/blob/master/LICENSE) -[![GoDoc](https://godoc.org/github.com/thrasher-corp/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-corp/gocryptotrader/engine/currency_state_manager) -[![Coverage Status](https://codecov.io/gh/thrasher-corp/gocryptotrader/graph/badge.svg?token=41784B23TS)](https://codecov.io/gh/thrasher-corp/gocryptotrader) -[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-corp/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-corp/gocryptotrader) - - -This currency_state_manager package is part of the GoCryptoTrader codebase. - -## This is still in active development - -You can track ideas, planned features and what's in progress on our [GoCryptoTrader Kanban board](https://github.com/orgs/thrasher-corp/projects/3). - -Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://join.slack.com/t/gocryptotrader/shared_invite/enQtNTQ5NDAxMjA2Mjc5LTc5ZDE1ZTNiOGM3ZGMyMmY1NTAxYWZhODE0MWM5N2JlZDk1NDU0YTViYzk4NTk3OTRiMDQzNGQ1YTc4YmRlMTk) +# GoCryptoTrader package Currency state manager + + + + +[![Build Status](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml) +[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-corp/gocryptotrader/blob/master/LICENSE) +[![GoDoc](https://godoc.org/github.com/thrasher-corp/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-corp/gocryptotrader/engine/currency_state_manager) +[![Coverage Status](https://codecov.io/gh/thrasher-corp/gocryptotrader/graph/badge.svg?token=41784B23TS)](https://codecov.io/gh/thrasher-corp/gocryptotrader) +[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-corp/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-corp/gocryptotrader) + + +This currency_state_manager package is part of the GoCryptoTrader codebase. + +## This is still in active development + +You can track ideas, planned features and what's in progress on our [GoCryptoTrader Kanban board](https://github.com/orgs/thrasher-corp/projects/3). + +Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://join.slack.com/t/gocryptotrader/shared_invite/enQtNTQ5NDAxMjA2Mjc5LTc5ZDE1ZTNiOGM3ZGMyMmY1NTAxYWZhODE0MWM5N2JlZDk1NDU0YTViYzk4NTk3OTRiMDQzNGQ1YTc4YmRlMTk) ## Current Features for Currency state manager + The state manager keeps currency states up to date, which include: @@ -27,22 +27,22 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader + This allows for an internal state check to compliment internal and external strategies. - -## Contribution - -Please feel free to submit any pull requests or suggest any desired features to be added. - -When submitting a PR, please abide by our coding guidelines: - -+ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). -+ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. -+ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/doc/coding_style.md). -+ Pull requests need to be based on and opened against the `master` branch. - -## Donations - - - -If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to: - + +## Contribution + +Please feel free to submit any pull requests or suggest any desired features to be added. + +When submitting a PR, please abide by our coding guidelines: + ++ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). ++ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. ++ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/doc/coding_style.md). ++ Pull requests need to be based on and opened against the `master` branch. + +## Donations + + + +If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to: + ***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc*** From b8a507002ac1aa9763848721ad0e768af031cb36 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 20 Feb 2025 10:48:52 +1100 Subject: [PATCH 26/34] screen 386 --- README.md | 2 +- cmd/documentation/root_templates/root_readme.tmpl | 2 +- encoding/json/json.go | 2 +- encoding/json/sonic.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e48a6cc14d8..e0e6d1a5b27 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ However, we welcome pull requests for any exchange which does not match this cri + WebGUI (discontinued). + Exchange HTTP mock testing. See [mock](/exchanges/mock/README.md). + Exchange multichain deposits and withdrawals for specific exchanges. See [multichain transfer support](/docs/MULTICHAIN_TRANSFER_SUPPORT.md). -+ Sonic JSON Integration. Revert back to the default Go 'encoding/json' package from the sonic library using go build tags `-tags=sonic_off` or by using the make file `make no_sonic` ++ Sonic JSON Integration. Revert back to the default Go 'encoding/json' package from the sonic library using go build tags `-tags=sonic_off`, by using the make file `make no_sonic`, or when compiling for a 32-bit architecture (GOARCH=386). ## Development Tracking diff --git a/cmd/documentation/root_templates/root_readme.tmpl b/cmd/documentation/root_templates/root_readme.tmpl index f2e93805f93..f469adcbd67 100644 --- a/cmd/documentation/root_templates/root_readme.tmpl +++ b/cmd/documentation/root_templates/root_readme.tmpl @@ -78,7 +78,7 @@ However, we welcome pull requests for any exchange which does not match this cri + WebGUI (discontinued). + Exchange HTTP mock testing. See [mock](/exchanges/mock/README.md). + Exchange multichain deposits and withdrawals for specific exchanges. See [multichain transfer support](/docs/MULTICHAIN_TRANSFER_SUPPORT.md). -+ Sonic JSON Integration. Revert back to the default Go 'encoding/json' package from the sonic library using go build tags `-tags=sonic_off` or by using the make file `make no_sonic` ++ Sonic JSON Integration. Revert back to the default Go 'encoding/json' package from the sonic library using go build tags `-tags=sonic_off`, by using the make file `make no_sonic`, or when compiling for a 32-bit architecture (GOARCH=386). ## Development Tracking diff --git a/encoding/json/json.go b/encoding/json/json.go index 6631b46e14c..da6bea520c9 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -1,4 +1,4 @@ -//go:build sonic_off +//go:build sonic_off || 386 package json diff --git a/encoding/json/sonic.go b/encoding/json/sonic.go index 5e5a913210b..d3c74bc07ee 100644 --- a/encoding/json/sonic.go +++ b/encoding/json/sonic.go @@ -1,4 +1,4 @@ -//go:build !sonic_off +//go:build !sonic_off && !386 package json From 9a52e1910f2e5304b81bd67bb113c83a7699b2cb Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 20 Feb 2025 11:20:51 +1100 Subject: [PATCH 27/34] linter: fix --- config/versions/versions.go | 2 +- exchanges/bitfinex/bitfinex_test.go | 2 +- exchanges/bitfinex/bitfinex_types.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/versions/versions.go b/config/versions/versions.go index 2335b8f1d63..cdaa66005c5 100644 --- a/config/versions/versions.go +++ b/config/versions/versions.go @@ -13,7 +13,7 @@ package versions import ( "bytes" "context" - "encoding/json" + "encoding/json" //nolint:depguard // Used instead of gct encoding/json so that we can ensure consistent library functionality between versions "errors" "fmt" "log" diff --git a/exchanges/bitfinex/bitfinex_test.go b/exchanges/bitfinex/bitfinex_test.go index 35a53c9bd9e..1340b7cbae9 100644 --- a/exchanges/bitfinex/bitfinex_test.go +++ b/exchanges/bitfinex/bitfinex_test.go @@ -3,7 +3,6 @@ package bitfinex import ( "bufio" "context" - "encoding/json" "errors" "log" "os" @@ -17,6 +16,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/core" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/kline" diff --git a/exchanges/bitfinex/bitfinex_types.go b/exchanges/bitfinex/bitfinex_types.go index ef013496305..c73e7a2b553 100644 --- a/exchanges/bitfinex/bitfinex_types.go +++ b/exchanges/bitfinex/bitfinex_types.go @@ -1,13 +1,13 @@ package bitfinex import ( - "encoding/json" "errors" "sync" "time" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/encoding/json" "github.com/thrasher-corp/gocryptotrader/exchanges/order" "github.com/thrasher-corp/gocryptotrader/types" ) From 9c154ca77bf84588c2c7202f9dd542950be3a2bd Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 20 Feb 2025 11:23:37 +1100 Subject: [PATCH 28/34] Add commentary --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3926bd9d67d..7cec91915d5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: goarch: 386 psql: true skip_wrapper_tests: true - sonic: true + sonic: true # sonic is disabled for 386 this ensures fall back to legacy code - os: macos-latest goarch: amd64 psql: true From ce013760b01dafa717e29345479bbca224225faa Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 20 Feb 2025 14:14:35 +1100 Subject: [PATCH 29/34] glorious: nits Makefile not working --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 49791ee028b..35f2e3efdeb 100644 --- a/Makefile +++ b/Makefile @@ -81,4 +81,4 @@ check-jq: .PHONY: no_sonic no_sonic: - go build -tags=sonic_off ./... \ No newline at end of file + go build $(LDFLAGS) -tags "sonic_off" \ No newline at end of file From fcc0b27e2ccc9a6884f8fb29095e98fa743bd13c Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 20 Feb 2025 14:45:56 +1100 Subject: [PATCH 30/34] gk: nits --- README.md | 19 +++++++++++-------- .../root_templates/root_readme.tmpl | 19 +++++++++++-------- encoding/json/common.go | 5 ++++- encoding/json/json.go | 2 +- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index e0e6d1a5b27..0052b38ae44 100644 --- a/README.md +++ b/README.md @@ -101,15 +101,11 @@ When submitting a PR, please abide by our coding guidelines: + Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/.github/CONTRIBUTING.md). + Pull requests need to be based on and opened against the `master` branch. -## Compiling instructions +## Compilation and run instructions -Download and install Go from [Go Downloads](https://golang.org/dl/) for your -platform. +Download and install Go from [Go Downloads](https://golang.org/dl/) for your platform. -### Linux/OSX - -GoCryptoTrader is built using [Go Modules](https://github.com/golang/go/wiki/Modules) and requires Go 1.11 or above -Using Go Modules you now clone this repository **outside** your GOPATH +### Linux/macOS ```bash git clone https://github.com/thrasher-corp/gocryptotrader.git @@ -125,11 +121,18 @@ cp config_example.json ~/.gocryptotrader/config.json git clone https://github.com/thrasher-corp/gocryptotrader.git cd gocryptotrader go build +mkdir %AppData%\GoCryptoTrader copy config_example.json %APPDATA%\GoCryptoTrader\config.json ``` +By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance. To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag: + +```bash +go build -tags=sonic_off +``` + + Make any necessary changes to the `config.json` file. -+ Run the `gocryptotrader` binary file inside your GOPATH bin folder. ++ Run the gocryptotrader binary file. ## Donations diff --git a/cmd/documentation/root_templates/root_readme.tmpl b/cmd/documentation/root_templates/root_readme.tmpl index f469adcbd67..cd5f04984ee 100644 --- a/cmd/documentation/root_templates/root_readme.tmpl +++ b/cmd/documentation/root_templates/root_readme.tmpl @@ -102,15 +102,11 @@ When submitting a PR, please abide by our coding guidelines: + Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/.github/CONTRIBUTING.md). + Pull requests need to be based on and opened against the `master` branch. -## Compiling instructions +## Compilation and run instructions -Download and install Go from [Go Downloads](https://golang.org/dl/) for your -platform. +Download and install Go from [Go Downloads](https://golang.org/dl/) for your platform. -### Linux/OSX - -GoCryptoTrader is built using [Go Modules](https://github.com/golang/go/wiki/Modules) and requires Go 1.11 or above -Using Go Modules you now clone this repository **outside** your GOPATH +### Linux/macOS ```bash git clone https://github.com/thrasher-corp/gocryptotrader.git @@ -126,11 +122,18 @@ cp config_example.json ~/.gocryptotrader/config.json git clone https://github.com/thrasher-corp/gocryptotrader.git cd gocryptotrader go build +mkdir %AppData%\GoCryptoTrader copy config_example.json %APPDATA%\GoCryptoTrader\config.json ``` +By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance. To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag: + +```bash +go build -tags=sonic_off +``` + + Make any necessary changes to the `config.json` file. -+ Run the `gocryptotrader` binary file inside your GOPATH bin folder. ++ Run the gocryptotrader binary file. {{template "donations" .}} diff --git a/encoding/json/common.go b/encoding/json/common.go index d12831007f0..287217aef67 100644 --- a/encoding/json/common.go +++ b/encoding/json/common.go @@ -1,6 +1,9 @@ +// json is an abstraction middleware package to allow switching between json encoder/decoder implementations +// The default implementation is sonic. +// Build with `sonic_off` or `386` tags to switch to golang.org/encoding/json. package json -import "encoding/json" //nolint:depguard // This is a wrapper package for encoding/json. All uses of JSON throughout the application should refer to this package in all builds. +import "encoding/json" //nolint:depguard // Acceptable use in gct json wrapper type ( // RawMessage is a raw encoded JSON value. diff --git a/encoding/json/json.go b/encoding/json/json.go index da6bea520c9..66f5abb3204 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -2,7 +2,7 @@ package json -import "encoding/json" //nolint:depguard // This is a wrapper package for encoding/json. All uses of JSON throughout the application should refer to this when sonic_off build tag is used. +import "encoding/json" //nolint:depguard // Acceptable use in gct json wrapper // Implementation is a constant string that represents the current JSON implementation package const Implementation = "encoding/json" From d49cf8e43b9e167cce14b4b6cacb7dbf5637fdf5 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 20 Feb 2025 14:48:09 +1100 Subject: [PATCH 31/34] gk: nits whoops --- README.md | 1 - cmd/documentation/root_templates/root_readme.tmpl | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index 0052b38ae44..ccfa377c740 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,6 @@ However, we welcome pull requests for any exchange which does not match this cri + WebGUI (discontinued). + Exchange HTTP mock testing. See [mock](/exchanges/mock/README.md). + Exchange multichain deposits and withdrawals for specific exchanges. See [multichain transfer support](/docs/MULTICHAIN_TRANSFER_SUPPORT.md). -+ Sonic JSON Integration. Revert back to the default Go 'encoding/json' package from the sonic library using go build tags `-tags=sonic_off`, by using the make file `make no_sonic`, or when compiling for a 32-bit architecture (GOARCH=386). ## Development Tracking diff --git a/cmd/documentation/root_templates/root_readme.tmpl b/cmd/documentation/root_templates/root_readme.tmpl index cd5f04984ee..b41f85022d5 100644 --- a/cmd/documentation/root_templates/root_readme.tmpl +++ b/cmd/documentation/root_templates/root_readme.tmpl @@ -78,7 +78,6 @@ However, we welcome pull requests for any exchange which does not match this cri + WebGUI (discontinued). + Exchange HTTP mock testing. See [mock](/exchanges/mock/README.md). + Exchange multichain deposits and withdrawals for specific exchanges. See [multichain transfer support](/docs/MULTICHAIN_TRANSFER_SUPPORT.md). -+ Sonic JSON Integration. Revert back to the default Go 'encoding/json' package from the sonic library using go build tags `-tags=sonic_off`, by using the make file `make no_sonic`, or when compiling for a 32-bit architecture (GOARCH=386). ## Development Tracking From ad20589d1e53a82b87dbbe6766cca80c420b7d97 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 20 Feb 2025 14:52:55 +1100 Subject: [PATCH 32/34] whoopsirino --- README.md | 2 +- cmd/documentation/root_templates/root_readme.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ccfa377c740..7642eda7fb0 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ go build -tags=sonic_off ``` + Make any necessary changes to the `config.json` file. -+ Run the gocryptotrader binary file. ++ Run the `gocryptotrader` binary file. ## Donations diff --git a/cmd/documentation/root_templates/root_readme.tmpl b/cmd/documentation/root_templates/root_readme.tmpl index b41f85022d5..b6a40e0133c 100644 --- a/cmd/documentation/root_templates/root_readme.tmpl +++ b/cmd/documentation/root_templates/root_readme.tmpl @@ -132,7 +132,7 @@ go build -tags=sonic_off ``` + Make any necessary changes to the `config.json` file. -+ Run the gocryptotrader binary file. ++ Run the `gocryptotrader` binary file. {{template "donations" .}} From c1f1216f48e1cb4ded74477fa3690076b0e64448 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 20 Feb 2025 14:56:46 +1100 Subject: [PATCH 33/34] mention 32bit systems won't be sonic --- README.md | 2 +- cmd/documentation/root_templates/root_readme.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7642eda7fb0..c8c6e2a2392 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ mkdir %AppData%\GoCryptoTrader copy config_example.json %APPDATA%\GoCryptoTrader\config.json ``` -By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance. To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag: +By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance unless compiling for a 32-bit architecture (GOARCH=386). To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag: ```bash go build -tags=sonic_off diff --git a/cmd/documentation/root_templates/root_readme.tmpl b/cmd/documentation/root_templates/root_readme.tmpl index b6a40e0133c..cd211a331a2 100644 --- a/cmd/documentation/root_templates/root_readme.tmpl +++ b/cmd/documentation/root_templates/root_readme.tmpl @@ -125,7 +125,7 @@ mkdir %AppData%\GoCryptoTrader copy config_example.json %APPDATA%\GoCryptoTrader\config.json ``` -By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance. To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag: +By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance unless compiling for a 32-bit architecture (GOARCH=386). To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag: ```bash go build -tags=sonic_off From 00ebc202a653e6722b7d9a6512a9c71bd70fd319 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Thu, 20 Feb 2025 15:07:15 +1100 Subject: [PATCH 34/34] gk: super-duper nit of extremes --- README.md | 2 +- cmd/documentation/root_templates/root_readme.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c8c6e2a2392..0a6a68dfd73 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ When submitting a PR, please abide by our coding guidelines: + Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/.github/CONTRIBUTING.md). + Pull requests need to be based on and opened against the `master` branch. -## Compilation and run instructions +## Compiling and Running instructions Download and install Go from [Go Downloads](https://golang.org/dl/) for your platform. diff --git a/cmd/documentation/root_templates/root_readme.tmpl b/cmd/documentation/root_templates/root_readme.tmpl index cd211a331a2..11b17a6b019 100644 --- a/cmd/documentation/root_templates/root_readme.tmpl +++ b/cmd/documentation/root_templates/root_readme.tmpl @@ -101,7 +101,7 @@ When submitting a PR, please abide by our coding guidelines: + Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/.github/CONTRIBUTING.md). + Pull requests need to be based on and opened against the `master` branch. -## Compilation and run instructions +## Compiling and Running instructions Download and install Go from [Go Downloads](https://golang.org/dl/) for your platform.