mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-07 23:16:53 +00:00
CI: Fix golangci-lint linter issues, add prealloc linter and bump version depends for Go 1.18 (#915)
* Bump CI versions * Specifically set go version as 1.17.x bumps it to 1.18 * Another * Adjust AppVeyor * Part 1 of linter issues * Part 2 * Fix various linters and improvements * Part 3 * Finishing touches * Tests and EqualFold * Fix nitterinos plus bonus requester jobs bump for exchanges with large number of tests * Fix nitterinos and bump golangci-lint timeout for AppVeyor * Address nits, ensure all books are returned on err due to syncer regression * Fix the wiggins * Fix duplication * Fix nitterinos
This commit is contained in:
@@ -42,7 +42,7 @@ func MatchURLVals(v1, v2 url.Values) bool {
|
||||
// DeriveURLValsFromJSONMap gets url vals from a map[string]string encoded JSON body
|
||||
func DeriveURLValsFromJSONMap(payload []byte) (url.Values, error) {
|
||||
var vals = url.Values{}
|
||||
if string(payload) == "" {
|
||||
if len(payload) == 0 {
|
||||
return vals, nil
|
||||
}
|
||||
intermediary := make(map[string]interface{})
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -48,7 +48,7 @@ func HTTPRecord(res *http.Response, service string, respContents []byte) error {
|
||||
|
||||
fileout := filepath.Join(DefaultDirectory, service, service+".json")
|
||||
|
||||
contents, err := ioutil.ReadFile(fileout)
|
||||
contents, err := os.ReadFile(fileout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func HTTPRecord(res *http.Response, service string, respContents []byte) error {
|
||||
if bodyErr != nil {
|
||||
return bodyErr
|
||||
}
|
||||
payload, bodyErr := ioutil.ReadAll(bodycopy)
|
||||
payload, bodyErr := io.ReadAll(bodycopy)
|
||||
if bodyErr != nil {
|
||||
return bodyErr
|
||||
}
|
||||
@@ -298,11 +298,10 @@ const (
|
||||
|
||||
// CheckJSON recursively parses json data to retract keywords, quite intensive.
|
||||
func CheckJSON(data interface{}, excluded *Exclusion) (interface{}, error) {
|
||||
var context map[string]interface{}
|
||||
if reflect.TypeOf(data).String() == "[]interface {}" {
|
||||
if d, ok := data.([]interface{}); ok {
|
||||
var sData []interface{}
|
||||
for i := range data.([]interface{}) {
|
||||
v := data.([]interface{})[i]
|
||||
for i := range d {
|
||||
v := d[i]
|
||||
switch v.(type) {
|
||||
case map[string]interface{}, []interface{}:
|
||||
checkedData, err := CheckJSON(v, excluded)
|
||||
@@ -324,6 +323,7 @@ func CheckJSON(data interface{}, excluded *Exclusion) (interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var context map[string]interface{}
|
||||
err = json.Unmarshal(conv, &context)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -426,7 +426,7 @@ func GetExcludedItems() (Exclusion, error) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
if !set {
|
||||
file, err := ioutil.ReadFile(exclusionFile)
|
||||
file, err := os.ReadFile(exclusionFile)
|
||||
if err != nil {
|
||||
if !strings.Contains(err.Error(), "no such file or directory") {
|
||||
return excludedList, err
|
||||
@@ -440,7 +440,7 @@ func GetExcludedItems() (Exclusion, error) {
|
||||
return excludedList, mErr
|
||||
}
|
||||
|
||||
mErr = ioutil.WriteFile(exclusionFile, data, os.ModePerm)
|
||||
mErr = os.WriteFile(exclusionFile, data, os.ModePerm)
|
||||
if mErr != nil {
|
||||
return excludedList, mErr
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -42,7 +43,7 @@ func NewVCRServer(path string) (string, *http.Client, error) {
|
||||
|
||||
var mockFile VCRMock
|
||||
|
||||
contents, err := ioutil.ReadFile(path)
|
||||
contents, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
pathing := strings.Split(path, "/")
|
||||
dirPathing := pathing[:len(pathing)-1]
|
||||
@@ -126,7 +127,7 @@ func RegisterHandler(pattern string, mock map[string][]HTTPResponse, mux *http.S
|
||||
case http.MethodPost, http.MethodPut:
|
||||
switch r.Header.Get(contentType) {
|
||||
case applicationURLEncoded:
|
||||
readBody, err := ioutil.ReadAll(r.Body)
|
||||
readBody, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
log.Fatal("Mock Test Failure - ReadAll error", err)
|
||||
}
|
||||
@@ -154,7 +155,7 @@ func RegisterHandler(pattern string, mock map[string][]HTTPResponse, mux *http.S
|
||||
return
|
||||
|
||||
case applicationJSON:
|
||||
readBody, err := ioutil.ReadAll(r.Body)
|
||||
readBody, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
log.Fatalf("Mock Test Failure - %v", err)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -48,7 +47,7 @@ func TestNewVCRServer(t *testing.T) {
|
||||
t.Fatal("marshal error", err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(testFile, payload, os.ModePerm)
|
||||
err = os.WriteFile(testFile, payload, os.ModePerm)
|
||||
if err != nil {
|
||||
t.Fatal("marshal error", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user