fix mod command lint errors

Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com>
This commit is contained in:
Tihomir Jovicic 2021-08-09 07:48:45 +02:00
parent c7653dc09c
commit 29ddcca32e
2 changed files with 7 additions and 9 deletions

View File

@ -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")
}
}

View File

@ -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 {