Fixes for govet

This commit is contained in:
Kirill Muratov 2019-03-22 23:05:19 +03:00
parent c31948caeb
commit 5059f0bee6
6 changed files with 25 additions and 26 deletions

View File

@ -8,5 +8,4 @@ output:
linters:
disable:
- errcheck
- govet
- staticcheck

View File

@ -126,7 +126,7 @@ func (g *Github) Close() error {
func (g *Github) First() (version uint, er error) {
if v, ok := g.migrations.First(); !ok {
return 0, &os.PathError{"first", g.path, os.ErrNotExist}
return 0, &os.PathError{Op: "first", Path: g.path, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -134,7 +134,7 @@ func (g *Github) First() (version uint, er error) {
func (g *Github) Prev(version uint) (prevVersion uint, err error) {
if v, ok := g.migrations.Prev(version); !ok {
return 0, &os.PathError{fmt.Sprintf("prev for version %v", version), g.path, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("prev for version %v", version), Path: g.path, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -142,7 +142,7 @@ func (g *Github) Prev(version uint) (prevVersion uint, err error) {
func (g *Github) Next(version uint) (nextVersion uint, err error) {
if v, ok := g.migrations.Next(version); !ok {
return 0, &os.PathError{fmt.Sprintf("next for version %v", version), g.path, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("next for version %v", version), Path: g.path, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -162,7 +162,7 @@ func (g *Github) ReadUp(version uint) (r io.ReadCloser, identifier string, err e
return ioutil.NopCloser(strings.NewReader(r)), m.Identifier, nil
}
}
return nil, "", &os.PathError{fmt.Sprintf("read version %v", version), g.path, os.ErrNotExist}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: g.path, Err: os.ErrNotExist}
}
func (g *Github) ReadDown(version uint) (r io.ReadCloser, identifier string, err error) {
@ -179,5 +179,5 @@ func (g *Github) ReadDown(version uint) (r io.ReadCloser, identifier string, err
return ioutil.NopCloser(strings.NewReader(r)), m.Identifier, nil
}
}
return nil, "", &os.PathError{fmt.Sprintf("read version %v", version), g.path, os.ErrNotExist}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: g.path, Err: os.ErrNotExist}
}

View File

@ -159,7 +159,7 @@ func (g *Gitlab) Close() error {
func (g *Gitlab) First() (version uint, er error) {
if v, ok := g.migrations.First(); !ok {
return 0, &os.PathError{"first", g.path, os.ErrNotExist}
return 0, &os.PathError{Op: "first", Path: g.path, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -167,7 +167,7 @@ func (g *Gitlab) First() (version uint, er error) {
func (g *Gitlab) Prev(version uint) (prevVersion uint, err error) {
if v, ok := g.migrations.Prev(version); !ok {
return 0, &os.PathError{fmt.Sprintf("prev for version %v", version), g.path, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("prev for version %v", version), Path: g.path, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -175,7 +175,7 @@ func (g *Gitlab) Prev(version uint) (prevVersion uint, err error) {
func (g *Gitlab) Next(version uint) (nextVersion uint, err error) {
if v, ok := g.migrations.Next(version); !ok {
return 0, &os.PathError{fmt.Sprintf("next for version %v", version), g.path, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("next for version %v", version), Path: g.path, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -200,7 +200,7 @@ func (g *Gitlab) ReadUp(version uint) (r io.ReadCloser, identifier string, err e
return ioutil.NopCloser(strings.NewReader(string(content))), m.Identifier, nil
}
return nil, "", &os.PathError{fmt.Sprintf("read version %v", version), g.path, os.ErrNotExist}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: g.path, Err: os.ErrNotExist}
}
func (g *Gitlab) ReadDown(version uint) (r io.ReadCloser, identifier string, err error) {
@ -222,5 +222,5 @@ func (g *Gitlab) ReadDown(version uint) (r io.ReadCloser, identifier string, err
return ioutil.NopCloser(strings.NewReader(string(content))), m.Identifier, nil
}
return nil, "", &os.PathError{fmt.Sprintf("read version %v", version), g.path, os.ErrNotExist}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: g.path, Err: os.ErrNotExist}
}

View File

@ -74,7 +74,7 @@ func (b *Bindata) Close() error {
func (b *Bindata) First() (version uint, err error) {
if v, ok := b.migrations.First(); !ok {
return 0, &os.PathError{"first", b.path, os.ErrNotExist}
return 0, &os.PathError{Op: "first", Path: b.path, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -82,7 +82,7 @@ func (b *Bindata) First() (version uint, err error) {
func (b *Bindata) Prev(version uint) (prevVersion uint, err error) {
if v, ok := b.migrations.Prev(version); !ok {
return 0, &os.PathError{fmt.Sprintf("prev for version %v", version), b.path, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("prev for version %v", version), Path: b.path, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -90,7 +90,7 @@ func (b *Bindata) Prev(version uint) (prevVersion uint, err error) {
func (b *Bindata) Next(version uint) (nextVersion uint, err error) {
if v, ok := b.migrations.Next(version); !ok {
return 0, &os.PathError{fmt.Sprintf("next for version %v", version), b.path, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("next for version %v", version), Path: b.path, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -104,7 +104,7 @@ func (b *Bindata) ReadUp(version uint) (r io.ReadCloser, identifier string, err
}
return ioutil.NopCloser(bytes.NewReader(body)), m.Identifier, nil
}
return nil, "", &os.PathError{fmt.Sprintf("read version %v", version), b.path, os.ErrNotExist}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: b.path, Err: os.ErrNotExist}
}
func (b *Bindata) ReadDown(version uint) (r io.ReadCloser, identifier string, err error) {
@ -115,5 +115,5 @@ func (b *Bindata) ReadDown(version uint) (r io.ReadCloser, identifier string, er
}
return ioutil.NopCloser(bytes.NewReader(body)), m.Identifier, nil
}
return nil, "", &os.PathError{fmt.Sprintf("read version %v", version), b.path, os.ErrNotExist}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: b.path, Err: os.ErrNotExist}
}

View File

@ -83,7 +83,7 @@ func (b *VFS) Close() error {
func (b *VFS) First() (version uint, err error) {
v, ok := b.migrations.First()
if !ok {
return 0, &os.PathError{"first", "<vfs>://" + b.path, os.ErrNotExist}
return 0, &os.PathError{Op: "first", Path: "<vfs>://" + b.path, Err: os.ErrNotExist}
}
return v, nil
}
@ -93,7 +93,7 @@ func (b *VFS) First() (version uint, err error) {
func (b *VFS) Prev(version uint) (prevVersion uint, err error) {
v, ok := b.migrations.Prev(version)
if !ok {
return 0, &os.PathError{fmt.Sprintf("prev for version %v", version), "<vfs>://" + b.path, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("prev for version %v", version), Path: "<vfs>://" + b.path, Err: os.ErrNotExist}
}
return v, nil
}
@ -103,7 +103,7 @@ func (b *VFS) Prev(version uint) (prevVersion uint, err error) {
func (b *VFS) Next(version uint) (nextVersion uint, err error) {
v, ok := b.migrations.Next(version)
if !ok {
return 0, &os.PathError{fmt.Sprintf("next for version %v", version), "<vfs>://" + b.path, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("next for version %v", version), Path: "<vfs>://" + b.path, Err: os.ErrNotExist}
}
return v, nil
}
@ -120,7 +120,7 @@ func (b *VFS) ReadUp(version uint) (r io.ReadCloser, identifier string, err erro
}
return ioutil.NopCloser(bytes.NewReader(body)), m.Identifier, nil
}
return nil, "", &os.PathError{fmt.Sprintf("read version %v", version), "<vfs>://" + b.path, os.ErrNotExist}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: "<vfs>://" + b.path, Err: os.ErrNotExist}
}
// ReadDown returns the down migration body and an identifier that helps with
@ -133,5 +133,5 @@ func (b *VFS) ReadDown(version uint) (r io.ReadCloser, identifier string, err er
}
return ioutil.NopCloser(bytes.NewReader(body)), m.Identifier, nil
}
return nil, "", &os.PathError{fmt.Sprintf("read version %v", version), "<vfs>://" + b.path, os.ErrNotExist}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: "<vfs>://" + b.path, Err: os.ErrNotExist}
}

View File

@ -48,7 +48,7 @@ func (s *Stub) Close() error {
func (s *Stub) First() (version uint, err error) {
if v, ok := s.Migrations.First(); !ok {
return 0, &os.PathError{"first", s.Url, os.ErrNotExist} // TODO: s.Url can be empty when called with WithInstance
return 0, &os.PathError{Op: "first", Path: s.Url, Err: os.ErrNotExist} // TODO: s.Url can be empty when called with WithInstance
} else {
return v, nil
}
@ -56,7 +56,7 @@ func (s *Stub) First() (version uint, err error) {
func (s *Stub) Prev(version uint) (prevVersion uint, err error) {
if v, ok := s.Migrations.Prev(version); !ok {
return 0, &os.PathError{fmt.Sprintf("prev for version %v", version), s.Url, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("prev for version %v", version), Path: s.Url, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -64,7 +64,7 @@ func (s *Stub) Prev(version uint) (prevVersion uint, err error) {
func (s *Stub) Next(version uint) (nextVersion uint, err error) {
if v, ok := s.Migrations.Next(version); !ok {
return 0, &os.PathError{fmt.Sprintf("next for version %v", version), s.Url, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("next for version %v", version), Path: s.Url, Err: os.ErrNotExist}
} else {
return v, nil
}
@ -74,12 +74,12 @@ func (s *Stub) ReadUp(version uint) (r io.ReadCloser, identifier string, err err
if m, ok := s.Migrations.Up(version); ok {
return ioutil.NopCloser(bytes.NewBufferString(m.Identifier)), fmt.Sprintf("%v.up.stub", version), nil
}
return nil, "", &os.PathError{fmt.Sprintf("read up version %v", version), s.Url, os.ErrNotExist}
return nil, "", &os.PathError{Op: fmt.Sprintf("read up version %v", version), Path: s.Url, Err: os.ErrNotExist}
}
func (s *Stub) ReadDown(version uint) (r io.ReadCloser, identifier string, err error) {
if m, ok := s.Migrations.Down(version); ok {
return ioutil.NopCloser(bytes.NewBufferString(m.Identifier)), fmt.Sprintf("%v.down.stub", version), nil
}
return nil, "", &os.PathError{fmt.Sprintf("read down version %v", version), s.Url, os.ErrNotExist}
return nil, "", &os.PathError{Op: fmt.Sprintf("read down version %v", version), Path: s.Url, Err: os.ErrNotExist}
}