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 {