linter: Enable gofumpt and run against codebase (#1848)

* linter: Enable gofumpt and run against codebase

* Address shazbert's nits

* gofumpt: Fix issues after rebase
This commit is contained in:
Adrian Gallagher
2025-03-18 10:23:16 +11:00
committed by GitHub
parent 748ed71455
commit f5faca2eb2
189 changed files with 1541 additions and 1104 deletions

View File

@@ -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{}
vals := url.Values{}
if len(payload) == 0 {
return vals, nil
}

View File

@@ -17,7 +17,7 @@ func TestMatchURLVals(t *testing.T) {
nonceVal1.Add("nonce", "012349723587")
nonceVal2.Add("nonce", "9327373874")
var expected = false
expected := false
received := MatchURLVals(testVal, emptyVal)
if received != expected {
t.Errorf("MatchURLVals error expected %v received %v",

View File

@@ -409,10 +409,12 @@ func IsExcluded(key string, excludedVars []string) bool {
return false
}
var excludedList Exclusion
var m sync.Mutex
var set bool
var exclusionFile = DefaultDirectory + "exclusion.json"
var (
excludedList Exclusion
m sync.Mutex
set bool
exclusionFile = DefaultDirectory + "exclusion.json"
)
var defaultExcludedHeaders = []string{
"Key",
@@ -421,6 +423,7 @@ var defaultExcludedHeaders = []string{
"Apiauth-Key",
"X-Bapi-Api-Key",
}
var defaultExcludedVariables = []string{
"bsb",
"user",

View File

@@ -249,7 +249,7 @@ func MatchAndGetResponse(mockData []HTTPResponse, requestVals url.Values, isQuer
data = mockData[i].BodyParams
}
var mockVals = url.Values{}
mockVals := url.Values{}
var err error
if json.Valid([]byte(data)) {
something := make(map[string]interface{})

View File

@@ -18,8 +18,10 @@ type responsePayload struct {
Currency string `json:"currency"`
}
const queryString = "currency=btc&command=getprice"
const testFile = "test.json"
const (
queryString = "currency=btc&command=getprice"
testFile = "test.json"
)
func TestNewVCRServer(t *testing.T) {
_, _, err := NewVCRServer("")
@@ -32,9 +34,11 @@ func TestNewVCRServer(t *testing.T) {
test1.Routes = make(map[string]map[string][]HTTPResponse)
test1.Routes["/test"] = make(map[string][]HTTPResponse)
rp, err := json.Marshal(responsePayload{Price: 8000.0,
rp, err := json.Marshal(responsePayload{
Price: 8000.0,
Amount: 1,
Currency: "bitcoin"})
Currency: "bitcoin",
})
if err != nil {
t.Fatal("marshal error", err)
}