From 29ddcca32ef14a28f289a6d41c51240d8454c4d7 Mon Sep 17 00:00:00 2001 From: Tihomir Jovicic Date: Mon, 9 Aug 2021 07:48:45 +0200 Subject: [PATCH] fix mod command lint errors Signed-off-by: Tihomir Jovicic --- cmd/dagger/cmd/mod/arg.go | 7 ++++--- cmd/dagger/cmd/mod/file.go | 9 +++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/dagger/cmd/mod/arg.go b/cmd/dagger/cmd/mod/arg.go index 8ab9e0d2..0efb2750 100644 --- a/cmd/dagger/cmd/mod/arg.go +++ b/cmd/dagger/cmd/mod/arg.go @@ -8,11 +8,12 @@ import ( ) func parseArgument(arg string) (*require, error) { - if strings.HasPrefix(arg, "github.com") { + switch { + case strings.HasPrefix(arg, "github.com"): return parseGithubRepoName(arg) - } else if strings.HasPrefix(arg, "alpha.dagger.io") { + case strings.HasPrefix(arg, "alpha.dagger.io"): return parseDaggerRepoName(arg) - } else { + default: return nil, fmt.Errorf("repo name does not match suported providers") } } diff --git a/cmd/dagger/cmd/mod/file.go b/cmd/dagger/cmd/mod/file.go index 9f3d3ab4..9fe164fd 100644 --- a/cmd/dagger/cmd/mod/file.go +++ b/cmd/dagger/cmd/mod/file.go @@ -42,10 +42,7 @@ func read(f io.Reader) (*file, error) { return nil, err } - lines, err := nonEmptyLines(b) - if err != nil { - return nil, err - } + lines := nonEmptyLines(b) if len(lines) == 0 { return nil, fmt.Errorf("mod file is empty, missing module name") @@ -77,7 +74,7 @@ func read(f io.Reader) (*file, error) { var spaceRgx = regexp.MustCompile(`\s+`) -func nonEmptyLines(b []byte) ([]string, error) { +func nonEmptyLines(b []byte) []string { s := strings.ReplaceAll(string(b), "\r\n", "\n") split := strings.Split(s, "\n") @@ -93,7 +90,7 @@ func nonEmptyLines(b []byte) ([]string, error) { lines = append(lines, trimmed) } - return lines, nil + return lines } func writeModFile(workspacePath string, f *file) error {