Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Brumhard <tobias.brumhard@mail.schwarz>
  • Loading branch information
brumhard committed Oct 30, 2021
1 parent 80efc94 commit b5379d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ issues:
- noctx
- goerr113
- funlen
- goconst
- path: dotembed/main\.go
linters:
- gochecknoglobals
Expand Down
2 changes: 1 addition & 1 deletion pkg/gocli/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Semver() (*semver.Version, error) {
}

versionParts := strings.Split(stdout.String(), " ")
if len(versionParts) != 4 {
if len(versionParts) != 4 { // nolint: gomnd // go version output has exactly 4 parts (e.g. "go version go1.17.2 darwin/amd64")
return nil, errors.Wrap(ErrMalformedGoVersionOutput, stdout.String())
}

Expand Down
15 changes: 8 additions & 7 deletions pkg/gotemplate/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import (
const minGoVersion = "1.15"

var (
ErrAlreadyExists = errors.New("already exists")
ErrParameterNotSet = errors.New("parameter not set")
ErrMalformedInput = errors.New("malformed input")
ErrParameterSet = errors.New("parameter set but has no effect in this context")
ErrAlreadyExists = errors.New("already exists")
ErrParameterNotSet = errors.New("parameter not set")
ErrMalformedInput = errors.New("malformed input")
ErrParameterSet = errors.New("parameter set but has no effect in this context")
ErrGoVersionNotSupported = fmt.Errorf("go version is not supported, gt requires at least %s", minGoVersion)

minGoVersionSemver = semver.MustParse(minGoVersion)
minGoVersionSemver = semver.MustParse(minGoVersion) // nolint: gochecknoglobals // parsed semver from const minGoVersion
)

type ErrTypeMismatch struct {
Expand Down Expand Up @@ -245,7 +246,7 @@ func (gt *GT) initRepo(targetDir, moduleName string) {
TargetDir: targetDir,
},
{
// PreRun: checkGoVersion,
PreRun: checkGoVersion,
Commands: []*exec.Cmd{
exec.Command("go", "mod", "init", moduleName),
exec.Command("go", "mod", "tidy"),
Expand Down Expand Up @@ -274,7 +275,7 @@ func checkGoVersion() error {
}

if goSemver.LessThan(minGoVersionSemver) {
return fmt.Errorf("go version %s is not supported, requires at least %s", goSemver.String(), minGoVersionSemver.String())
return errors.Wrap(ErrGoVersionNotSupported, goSemver.String())
}

return nil
Expand Down

0 comments on commit b5379d5

Please sign in to comment.