mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-03 23:16:53 +00:00
golangci-lint/CI: Bump versions and introduce new linters (#798)
* golangci-lint/CI: Bump versions
Fix remaining linter issues
* Specifically set AppVeyor version
* Fix the infamous typos 👀
* Add go env cmd to AppVeyor
* Add go version cmd to AppVeyor
* Specify AppVeyor image, adjust linters
* Update go get to go install due to deprecation
* Bump golangci-lint timeout time for AppVeyor
* Change NW contract to NQ
* Address nitters
* GetRandomPair -> Pair{}
* Address nits
* Address time nitterinos plus additional tweaks
* More time inception upgrades!
* Bending time and space
This commit is contained in:
@@ -52,7 +52,7 @@ func TimeFromUnixTimestampFloat(raw interface{}) (time.Time, error) {
|
||||
if !ok {
|
||||
return time.Time{}, fmt.Errorf("unable to parse, value not float64: %T", raw)
|
||||
}
|
||||
return time.Unix(0, int64(ts)*int64(time.Millisecond)), nil
|
||||
return time.UnixMilli(int64(ts)), nil
|
||||
}
|
||||
|
||||
// TimeFromUnixTimestampDecimal converts a unix timestamp in decimal form to
|
||||
@@ -76,23 +76,8 @@ func UnixTimestampStrToTime(timeStr string) (time.Time, error) {
|
||||
return time.Unix(i, 0), nil
|
||||
}
|
||||
|
||||
// UnixMillis converts a UnixNano timestamp to milliseconds
|
||||
func UnixMillis(t time.Time) int64 {
|
||||
return t.UnixNano() / int64(time.Millisecond)
|
||||
}
|
||||
|
||||
// RecvWindow converts a supplied time.Duration to milliseconds
|
||||
func RecvWindow(d time.Duration) int64 {
|
||||
return int64(d) / int64(time.Millisecond)
|
||||
}
|
||||
|
||||
// BoolPtr takes in boolen condition and returns pointer version of it
|
||||
func BoolPtr(condition bool) *bool {
|
||||
b := condition
|
||||
return &b
|
||||
}
|
||||
|
||||
// UnixMillisToNano converts Unix milli time to UnixNano
|
||||
func UnixMillisToNano(milli int64) int64 {
|
||||
return milli * int64(time.Millisecond)
|
||||
}
|
||||
|
||||
@@ -32,10 +32,8 @@ func TestFloatFromString(t *testing.T) {
|
||||
func TestIntFromString(t *testing.T) {
|
||||
t.Parallel()
|
||||
testString := "1337"
|
||||
expectedOutput := 1337
|
||||
|
||||
actualOutput, err := IntFromString(testString)
|
||||
if actualOutput != expectedOutput || err != nil {
|
||||
if expectedOutput := 1337; actualOutput != expectedOutput || err != nil {
|
||||
t.Errorf("Common IntFromString. Expected '%v'. Actual '%v'. Error: %s",
|
||||
expectedOutput, actualOutput, err)
|
||||
}
|
||||
@@ -136,33 +134,9 @@ func TestUnixTimestampStrToTime(t *testing.T) {
|
||||
t.Errorf(
|
||||
"Expected '%s'. Actual '%s'.", expectedOutput, actualResult)
|
||||
}
|
||||
actualResult, err = UnixTimestampStrToTime(incorrectTime)
|
||||
_, err = UnixTimestampStrToTime(incorrectTime)
|
||||
if err == nil {
|
||||
t.Error("Common UnixTimestampStrToTime error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnixMillis(t *testing.T) {
|
||||
t.Parallel()
|
||||
testTime := time.Date(2014, time.October, 28, 0, 32, 0, 0, time.UTC)
|
||||
expectedOutput := int64(1414456320000)
|
||||
|
||||
actualOutput := UnixMillis(testTime)
|
||||
if actualOutput != expectedOutput {
|
||||
t.Errorf("Common UnixMillis. Expected '%d'. Actual '%d'.",
|
||||
expectedOutput, actualOutput)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecvWindow(t *testing.T) {
|
||||
t.Parallel()
|
||||
testTime := time.Duration(24760000)
|
||||
expectedOutput := int64(24)
|
||||
|
||||
actualOutput := RecvWindow(testTime)
|
||||
if actualOutput != expectedOutput {
|
||||
t.Errorf("Common RecvWindow. Expected '%d'. Actual '%d'",
|
||||
expectedOutput, actualOutput)
|
||||
t.Error("should throw an error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,10 +150,3 @@ func TestBoolPtr(t *testing.T) {
|
||||
t.Fatal("false expected received true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnixMillisToNano(t *testing.T) {
|
||||
v := UnixMillisToNano(1588653603424)
|
||||
if v != 1588653603424000000 {
|
||||
t.Fatalf("unexpected result received %v", v)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user