Skip to content

Commit

Permalink
linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Scarr committed Jan 21, 2019
1 parent c6eb1a8 commit 0f88449
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func Execute() {
app.Before = func(context *cli.Context) error {
pwd, err := os.Getwd()
if err != nil {
return fmt.Errorf("unable to determine current workding dir: %s\n", err.Error())
return fmt.Errorf("unable to determine current workding dir: %s", err.Error())
}

if !gopath.Contains(pwd) {
return fmt.Errorf("gqlgen must be run from inside your $GOPATH\n")
return fmt.Errorf("gqlgen must be run from inside your $GOPATH")
}
if context.Bool("verbose") {
log.SetFlags(0)
Expand All @@ -47,7 +47,7 @@ func Execute() {
}

if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, err.Error())
fmt.Fprint(os.Stderr, err.Error())
os.Exit(1)
}
}
4 changes: 2 additions & 2 deletions codegen/templates/input.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
{{else}}
if data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok{
obj.{{$field.GoFieldName}} = data
}else{
return obj, errors.New("{{$field.GoFieldName}} expect {{$field.GoType | ref }}")
} else {
return obj, errors.New("expected {{$field.GoFieldName}} to be {{$field.GoType | ref }}")
}
{{ end }}

Expand Down
4 changes: 2 additions & 2 deletions codegen/testserver/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/scalars/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (b Banned) MarshalGQL(w io.Writer) {
func (b *Banned) UnmarshalGQL(v interface{}) error {
switch v := v.(type) {
case string:
*b = "true" == strings.ToLower(v)
*b = strings.ToLower(v) == "true"
return nil
case bool:
*b = Banned(v)
Expand Down
2 changes: 1 addition & 1 deletion graphql/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func MarshalBoolean(b bool) Marshaler {
func UnmarshalBoolean(v interface{}) (bool, error) {
switch v := v.(type) {
case string:
return "true" == strings.ToLower(v), nil
return strings.ToLower(v) == "true", nil
case int:
return v != 0, nil
case bool:
Expand Down
2 changes: 1 addition & 1 deletion integration/integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ describe('Errors', () => {
query: gql`{ error(type: NORMAL) }`,
});

expect(res.errors[0].message).toEqual('Normal error');
expect(res.errors[0].message).toEqual('normal error');
});
});
2 changes: 1 addition & 1 deletion integration/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (r *queryResolver) Error(ctx context.Context, typeArg *models.ErrorType) (b
return false, &CustomError{"User message", "Internal Message"}
}

return false, fmt.Errorf("Normal error")
return false, fmt.Errorf("normal error")
}

func (r *queryResolver) Path(ctx context.Context) ([]*models.Element, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/gopath/gopath.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
)

var NotFound = fmt.Errorf("not on GOPATH")
var ErrNotFound = fmt.Errorf("not on GOPATH")

// Contains returns true if the given directory is in the GOPATH
func Contains(dir string) bool {
Expand All @@ -24,7 +24,7 @@ func Dir2Import(dir string) (string, error) {
return dir[len(gopath)+1:], nil
}
}
return "", NotFound
return "", ErrNotFound
}

// MustDir2Import takes an *absolute* path and returns a golang import path for the package, and panics if it isn't on the gopath
Expand Down
4 changes: 2 additions & 2 deletions internal/gopath/gopath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestDir2Package(t *testing.T) {
assert.Equal(t, "foo/bar", MustDir2Import("C:/b/src/foo/bar"))
assert.Equal(t, "foo/bar", MustDir2Import(`C:\b\src\foo\bar`))

assert.PanicsWithValue(t, NotFound, func() {
assert.PanicsWithValue(t, ErrNotFound, func() {
MustDir2Import("C:/tmp/foo")
})
} else {
Expand All @@ -55,7 +55,7 @@ func TestDir2Package(t *testing.T) {
assert.Equal(t, "foo/bar", MustDir2Import("/a/y/src/foo/bar"))
assert.Equal(t, "foo/bar", MustDir2Import("/b/src/foo/bar"))

assert.PanicsWithValue(t, NotFound, func() {
assert.PanicsWithValue(t, ErrNotFound, func() {
MustDir2Import("/tmp/foo")
})
}
Expand Down

0 comments on commit 0f88449

Please sign in to comment.