Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go vet cli code #110

Merged
merged 2 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions cli/migrate/source/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (f *File) Close() error {

func (f *File) First() (version uint64, err error) {
if v, ok := f.migrations.First(); !ok {
return 0, &os.PathError{"first", f.path, os.ErrNotExist}
return 0, &os.PathError{Op: "first", Path: f.path, Err: os.ErrNotExist}
} else {
return v, nil
}
Expand All @@ -110,15 +110,15 @@ func (f *File) GetUnappliedMigrations(version uint64) (versions []uint64) {

func (f *File) Prev(version uint64) (prevVersion uint64, err error) {
if v, ok := f.migrations.Prev(version); !ok {
return 0, &os.PathError{fmt.Sprintf("prev for version %v", version), f.path, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("prev for version %v", version), Path: f.path, Err: os.ErrNotExist}
} else {
return v, nil
}
}

func (f *File) Next(version uint64) (nextVersion uint64, err error) {
if v, ok := f.migrations.Next(version); !ok {
return 0, &os.PathError{fmt.Sprintf("next for version %v", version), f.path, os.ErrNotExist}
return 0, &os.PathError{Op: fmt.Sprintf("next for version %v", version), Path: f.path, Err: os.ErrNotExist}
} else {
return v, nil
}
Expand All @@ -136,7 +136,7 @@ func (f *File) ReadUp(version uint64) (r io.ReadCloser, identifier string, fileN
}
return r, m.Identifier, m.Raw, nil
}
return nil, "", "", &os.PathError{fmt.Sprintf("read version %v", version), f.path, os.ErrNotExist}
return nil, "", "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: f.path, Err: os.ErrNotExist}
}

func (f *File) ReadMetaUp(version uint64) (r io.ReadCloser, identifier string, fileName string, err error) {
Expand All @@ -147,7 +147,7 @@ func (f *File) ReadMetaUp(version uint64) (r io.ReadCloser, identifier string, f
}
return r, m.Identifier, m.Raw, nil
}
return nil, "", "", &os.PathError{fmt.Sprintf("read version %v", version), f.path, os.ErrNotExist}
return nil, "", "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: f.path, Err: os.ErrNotExist}
}

func (f *File) ReadDown(version uint64) (r io.ReadCloser, identifier string, fileName string, err error) {
Expand All @@ -158,7 +158,7 @@ func (f *File) ReadDown(version uint64) (r io.ReadCloser, identifier string, fil
}
return r, m.Identifier, m.Raw, nil
}
return nil, "", "", &os.PathError{fmt.Sprintf("read version %v", version), f.path, os.ErrNotExist}
return nil, "", "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: f.path, Err: os.ErrNotExist}
}

func (f *File) ReadMetaDown(version uint64) (r io.ReadCloser, identifier string, fileName string, err error) {
Expand All @@ -169,5 +169,5 @@ func (f *File) ReadMetaDown(version uint64) (r io.ReadCloser, identifier string,
}
return r, m.Identifier, m.Raw, nil
}
return nil, "", "", &os.PathError{fmt.Sprintf("read version %v", version), f.path, os.ErrNotExist}
return nil, "", "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: f.path, Err: os.ErrNotExist}
}
14 changes: 7 additions & 7 deletions cli/migrate/source/stub/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ func (s *Stub) Close() error {

func (s *Stub) First() (version uint64, 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
}
}

func (s *Stub) Prev(version uint64) (prevVersion uint64, 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
}
}

func (s *Stub) Next(version uint64) (nextVersion uint64, 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
}
Expand All @@ -69,14 +69,14 @@ func (s *Stub) ReadUp(version uint64) (r io.ReadCloser, identifier string, fileN
if m, ok := s.Migrations.Up(version); ok {
return ioutil.NopCloser(bytes.NewBufferString(m.Identifier)), fmt.Sprintf("%v.up.sql.stub", version), fmt.Sprintf("%v.up.sql.stub", version), nil
}
return nil, "", "", &os.PathError{fmt.Sprintf("read up sql version %v", version), s.Url, os.ErrNotExist}
return nil, "", "", &os.PathError{Op: fmt.Sprintf("read up sql version %v", version), Path: s.Url, Err: os.ErrNotExist}
}

func (s *Stub) ReadDown(version uint64) (r io.ReadCloser, identifier string, fileName string, err error) {
if m, ok := s.Migrations.Down(version); ok {
return ioutil.NopCloser(bytes.NewBufferString(m.Identifier)), fmt.Sprintf("%v.down.sql.stub", version), fmt.Sprintf("%v.down.sql.stub", version), nil
}
return nil, "", "", &os.PathError{fmt.Sprintf("read down sql version %v", version), s.Url, os.ErrNotExist}
return nil, "", "", &os.PathError{Op: fmt.Sprintf("read down sql version %v", version), Path: s.Url, Err: os.ErrNotExist}
}

func (s *Stub) GetDirections(version uint64) map[source.Direction]bool {
Expand All @@ -95,12 +95,12 @@ func (s *Stub) ReadMetaUp(version uint64) (r io.ReadCloser, identifier string, f
if m, ok := s.Migrations.MetaUp(version); ok {
return ioutil.NopCloser(bytes.NewBufferString(m.Identifier)), fmt.Sprintf("%v.up.yaml.stub", version), fmt.Sprintf("%v.up.yaml.stub", version), nil
}
return nil, "", "", &os.PathError{fmt.Sprintf("read up yaml version %v", version), s.Url, os.ErrNotExist}
return nil, "", "", &os.PathError{Op: fmt.Sprintf("read up yaml version %v", version), Path: s.Url, Err: os.ErrNotExist}
}

func (s *Stub) ReadMetaDown(version uint64) (r io.ReadCloser, identifier string, fileName string, err error) {
if m, ok := s.Migrations.MetaDown(version); ok {
return ioutil.NopCloser(bytes.NewBufferString(m.Identifier)), fmt.Sprintf("%v.down.yaml.stub", version), fmt.Sprintf("%v.down.yaml.stub", version), nil
}
return nil, "", "", &os.PathError{fmt.Sprintf("read down yaml version %v", version), s.Url, os.ErrNotExist}
return nil, "", "", &os.PathError{Op: fmt.Sprintf("read down yaml version %v", version), Path: s.Url, Err: os.ErrNotExist}
}
2 changes: 1 addition & 1 deletion cli/version/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func FetchServerVersion(endpoint string) (version string, err error) {
case http.StatusNotFound:
return "", nil
default:
return "", errors.Errorf("GET %s failed - [%s]", versionEndpoint, response.StatusCode)
return "", errors.Errorf("GET %s failed - [%d]", versionEndpoint, response.StatusCode)
}
} else {
defer response.Body.Close()
Expand Down