Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnewhall committed Jan 21, 2024
1 parent 228c55a commit dd0b732
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codetests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: stable
- name: go-test
run: go test -race -covermode=atomic ./...
# Runs golangci-lint on macos against freebsd and macos.
Expand All @@ -31,7 +31,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: stable
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand All @@ -49,7 +49,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: stable
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
6 changes: 3 additions & 3 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestParseInt(t *testing.T) {
i, err := parseInt(t, fmt.Sprintf("%d", t))

assert.EqualValues(t, i)
assert.Nil(err)
assert.NoError(err)
}
}

Expand All @@ -34,7 +34,7 @@ func TestParseByteSlice(t *testing.T) { //nolint:paralleltest
ok, err := UnmarshalENV(testStruct, "D")

assert.True(ok)
assert.Nil(err)
assert.NoError(err)
assert.Equal("byte slice incoming", string(testStruct.F))
}

Expand All @@ -54,7 +54,7 @@ func TestParseUint(t *testing.T) {
err := parseUint(theField, t, "1")

assert.EqualValues(1, embeddedInt.F)
assert.Nil(err)
assert.NoError(err)
}

type test2 struct {
Expand Down
9 changes: 4 additions & 5 deletions unparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ func (p *unparser) Member(field reflect.Value, tag string, omitempty bool) (Pair
case time.Duration:
output.Set(tag, (time.Duration(field.Int()) * time.Nanosecond).String())
case bool:
output.Set(tag, fmt.Sprintf("%v", field.Bool()))
output.Set(tag, strconv.FormatBool(field.Bool()))
default:
return p.kindMember(field, tag, omitempty)
}

return output, nil
}

func (p *unparser) kindMember(field reflect.Value, tag string, omitempty bool) (Pairs, error) { //nolint:cyclop
func (p *unparser) kindMember(field reflect.Value, tag string, _ bool) (Pairs, error) {
output := Pairs{}

switch field.Kind() {
Expand All @@ -195,16 +195,15 @@ func (p *unparser) kindMember(field reflect.Value, tag string, omitempty bool) (
output.Set(tag, strconv.FormatUint(val, base10))
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
val, _ := field.Interface().(int64)
output.Set(tag, strconv.FormatInt(int64(val), base10))
output.Set(tag, strconv.FormatInt(val, base10))
case reflect.Float64:
val, _ := field.Interface().(float64)
output.Set(tag, strconv.FormatFloat(val, 'f', -1, bits64))
case reflect.Float32:
val, _ := field.Interface().(float32)
output.Set(tag, strconv.FormatFloat(float64(val), 'f', -1, bits32))
case reflect.Bool:
output.Set(tag, fmt.Sprintf("%v", field.Bool()))

output.Set(tag, strconv.FormatBool(field.Bool()))
}

return output, nil
Expand Down
8 changes: 5 additions & 3 deletions unparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ func marshalTestData() (*MarshalTest, int) {
Test: &MarshalTest{
Name: "subtest", // 24
Err: fmt.Errorf("this long error is here 2 line up the comments"), // 25
},
Imap: map[string]interface{}{"orange": "sunset", // 26
"pink": "sunrise", "counter": 8967, "floater": 3.1415926, // 27, 28, 29
}, Imap: map[string]interface{}{
"orange": "sunset", // 26
"pink": "sunrise", // 27
"counter": 8967, // 28
"floater": 3.1415926, // 29
}, // + 3 more from marshalTest2.Name2. That puts the total var count at 32.
}, 32 // set the count here.
}
Expand Down

0 comments on commit dd0b732

Please sign in to comment.