CI: Bump go version, linters and fix minor issues (#1010)

* Bump golang, golangci-lint versions and fix issues

* Add -fno-stack-protector

* Fix AppVeyor golangci-lint ver

* Nitters

* Nitters round 2
This commit is contained in:
Adrian Gallagher
2022-08-17 11:37:22 +10:00
committed by GitHub
parent 0c9ad9eaa3
commit 68588560e3
85 changed files with 389 additions and 246 deletions

View File

@@ -3,6 +3,8 @@ package postgres
import (
"database/sql"
"fmt"
"net"
"strconv"
// import go libpq driver package
_ "github.com/lib/pq"
@@ -21,11 +23,11 @@ func Connect(cfg *database.Config) (*database.Instance, error) {
cfg.SSLMode = "disable"
}
configDSN := fmt.Sprintf("postgres://%s:%s@%s:%d/%s?sslmode=%s",
host := net.JoinHostPort(cfg.Host, strconv.FormatUint(uint64(cfg.Port), 10))
configDSN := fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s",
cfg.Username,
cfg.Password,
cfg.Host,
cfg.Port,
host,
cfg.Database,
cfg.SSLMode)

View File

@@ -2,7 +2,6 @@ package audit
import (
"fmt"
"io/ioutil"
"os"
"sync"
"testing"
@@ -16,7 +15,7 @@ import (
func TestMain(m *testing.M) {
var err error
testhelpers.PostgresTestDatabase = testhelpers.GetConnectionDetails()
testhelpers.TempDir, err = ioutil.TempDir("", "gct-temp")
testhelpers.TempDir, err = os.MkdirTemp("", "gct-temp")
if err != nil {
fmt.Printf("failed to create temp file: %v", err)
os.Exit(1)

View File

@@ -3,7 +3,6 @@ package candle
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
@@ -39,7 +38,7 @@ func TestMain(m *testing.M) {
var err error
testhelpers.PostgresTestDatabase = testhelpers.GetConnectionDetails()
testhelpers.TempDir, err = ioutil.TempDir("", "gct-temp")
testhelpers.TempDir, err = os.MkdirTemp("", "gct-temp")
if err != nil {
fmt.Printf("failed to create temp file: %v", err)
os.Exit(1)

View File

@@ -3,7 +3,6 @@ package datahistoryjob
import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"strings"
@@ -41,7 +40,7 @@ func TestMain(m *testing.M) {
}
var err error
testhelpers.PostgresTestDatabase = testhelpers.GetConnectionDetails()
testhelpers.TempDir, err = ioutil.TempDir("", "gct-temp")
testhelpers.TempDir, err = os.MkdirTemp("", "gct-temp")
if err != nil {
log.Fatal(err)
}

View File

@@ -3,7 +3,6 @@ package datahistoryjobresult
import (
"database/sql"
"fmt"
"io/ioutil"
"log"
"os"
"testing"
@@ -38,7 +37,7 @@ func TestMain(m *testing.M) {
}
var err error
testhelpers.PostgresTestDatabase = testhelpers.GetConnectionDetails()
testhelpers.TempDir, err = ioutil.TempDir("", "gct-temp")
testhelpers.TempDir, err = os.MkdirTemp("", "gct-temp")
if err != nil {
log.Fatal(err)
}

View File

@@ -2,7 +2,6 @@ package exchange
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
@@ -39,7 +38,7 @@ func TestMain(m *testing.M) {
var err error
testhelpers.PostgresTestDatabase = testhelpers.GetConnectionDetails()
testhelpers.TempDir, err = ioutil.TempDir("", "gct-temp")
testhelpers.TempDir, err = os.MkdirTemp("", "gct-temp")
if err != nil {
fmt.Printf("failed to create temp file: %v", err)
os.Exit(1)

View File

@@ -2,7 +2,6 @@ package script
import (
"fmt"
"io/ioutil"
"os"
"sync"
"testing"
@@ -21,7 +20,7 @@ var (
func TestMain(m *testing.M) {
var err error
testhelpers.PostgresTestDatabase = testhelpers.GetConnectionDetails()
testhelpers.TempDir, err = ioutil.TempDir("", "gct-temp")
testhelpers.TempDir, err = os.MkdirTemp("", "gct-temp")
if err != nil {
fmt.Printf("failed to create temp file: %v", err)
os.Exit(1)

View File

@@ -2,7 +2,6 @@ package trade
import (
"fmt"
"io/ioutil"
"log"
"os"
"testing"
@@ -41,11 +40,16 @@ func TestMain(m *testing.M) {
}
var err error
testhelpers.PostgresTestDatabase = testhelpers.GetConnectionDetails()
testhelpers.TempDir, err = ioutil.TempDir("", "gct-temp")
testhelpers.TempDir, err = os.MkdirTemp("", "gct-temp")
if err != nil {
log.Fatal(err)
}
os.Exit(m.Run())
exitCode := m.Run()
if err = os.RemoveAll(testhelpers.TempDir); err != nil {
fmt.Printf("failed to remove temp dir: %s", err)
}
os.Exit(exitCode)
}
func TestTrades(t *testing.T) {

View File

@@ -3,7 +3,6 @@ package withdraw
import (
"errors"
"fmt"
"io/ioutil"
"math/rand"
"os"
"testing"
@@ -38,7 +37,7 @@ func TestMain(m *testing.M) {
var err error
testhelpers.PostgresTestDatabase = testhelpers.GetConnectionDetails()
testhelpers.TempDir, err = ioutil.TempDir("", "gct-temp")
testhelpers.TempDir, err = os.MkdirTemp("", "gct-temp")
if err != nil {
fmt.Printf("failed to create temp file: %v", err)
os.Exit(1)
@@ -139,7 +138,7 @@ func seedWithdrawData() {
},
},
}
rnd := rand.Intn(2) // nolint:gosec // used for generating test data, no need to import crypo/rand
rnd := rand.Intn(2) //nolint:gosec // used for generating test data, no need to import crypo/rand
if rnd == 0 {
resp.RequestDetails.Currency = currency.AUD
resp.RequestDetails.Type = 1

View File

@@ -2,7 +2,6 @@ package testhelpers
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
@@ -14,7 +13,7 @@ import (
func TestMain(m *testing.M) {
var err error
PostgresTestDatabase = GetConnectionDetails()
TempDir, err = ioutil.TempDir("", "gct-temp")
TempDir, err = os.MkdirTemp("", "gct-temp")
if err != nil {
fmt.Printf("failed to create temp file: %v", err)
os.Exit(1)