Skip to content

Commit

Permalink
fixing staticcheck errors
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfireman committed Mar 29, 2022
1 parent c3a8d20 commit f1112b4
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
4 changes: 0 additions & 4 deletions csv/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import (
"github.com/matryer/is"
)

type iterTestValue struct {
Name string
}

const (
dontSkipHeaders = false
skipHeaders = true
Expand Down
2 changes: 1 addition & 1 deletion csv/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func Remote(url string) Source {
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
return stringReadCloser(string(body)), nil
return stringReadCloser(string(body)), err
}
}

Expand Down
5 changes: 1 addition & 4 deletions csv/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import (
"github.com/matryer/is"
)

type csvRow struct {
Name string
}

func ExampleTable_Iter() {
table, _ := NewTable(FromString("\"name\"\nfoo\nbar"), LoadHeaders())
iter, _ := table.Iter()
Expand Down Expand Up @@ -158,6 +154,7 @@ func TestReadAll(t *testing.T) {
func() (io.ReadCloser, error) {
return nil, errors.New("this is a source test error")
})
is.NoErr(err)
_, err = table.ReadAll()
is.True(err != nil)
}
Expand Down
4 changes: 3 additions & 1 deletion examples/constraints/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ func main() {
Capital float64
URL string
}{}

if err != nil {
log.Fatalf("Error creating table: %q", err)
}
if err := capitalSchema.CastTable(table, &capitals); err != nil {
log.Fatalf("Error casting table: %q", err)
}
Expand Down
4 changes: 3 additions & 1 deletion examples/validate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ func main() {
Capital float64
URL string
}{}

if err != nil {
log.Fatalf("Error creating table: %q", err)
}
iter, _ := table.Iter()
for iter.Next() {
if err := capitalSchema.CastRow(iter.Row(), &capitalRow); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions schema/boolean.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ func castBoolean(value string, trueValues, falseValues []string) (bool, error) {
}

func uncastBoolean(value interface{}, trueValues, falseValues []string) (string, error) {
switch value.(type) {
switch val := value.(type) {
case bool:
return fmt.Sprintf("%v", value), nil
case string:
for _, v := range trueValues {
if value == v {
return value.(string), nil
return val, nil
}
}
for _, v := range falseValues {
if value == v {
return value.(string), nil
return val, nil
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion schema/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
func castDuration(value string) (time.Duration, error) {
matches := durationRegexp.FindStringSubmatch(value)
if len(matches) == 0 {
return 0, fmt.Errorf("Invalid duration:\"%s\"", value)
return 0, fmt.Errorf("invalid duration:\"%s\"", value)
}
years := parseIntDuration(matches[1], hoursInYear)
months := parseIntDuration(matches[2], hoursInMonth)
Expand Down
4 changes: 2 additions & 2 deletions schema/geopoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (p *GeoPoint) UnmarshalJSON(data []byte) error {
return err
}
if a.Lon == nil || a.Lat == nil {
return fmt.Errorf("Invalid geopoint:\"%s\"", string(data))
return fmt.Errorf("invalid geopoint:\"%s\"", string(data))
}
p.Lon = *a.Lon
p.Lat = *a.Lat
Expand Down Expand Up @@ -63,7 +63,7 @@ func castGeoPoint(format, value string) (GeoPoint, error) {
func applyGeoPointRegexp(r *regexp.Regexp, value string) (GeoPoint, error) {
matches := r.FindStringSubmatch(value)
if len(matches) == 0 || len(matches[1]) == 0 || len(matches[2]) == 0 {
return GeoPoint{}, fmt.Errorf("Invalid geopoint:\"%s\"", value)
return GeoPoint{}, fmt.Errorf("invalid geopoint:\"%s\"", value)
}
lon, _ := strconv.ParseFloat(matches[1], 64)
lat, _ := strconv.ParseFloat(matches[2], 64)
Expand Down

0 comments on commit f1112b4

Please sign in to comment.