Skip to content

Commit 5408301

Browse files
committed
fix: windows FS...
1 parent d26982e commit 5408301

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

pkg/lint/package.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,9 @@ func buildArgs(args []string) []string {
238238

239239
var retArgs []string
240240
for _, arg := range args {
241-
if strings.HasPrefix(arg, ".") {
242-
println("HasPrefix", arg)
243-
retArgs = append(retArgs, arg)
244-
} else if filepath.IsAbs(arg) {
245-
println("IsAbs", arg)
241+
if strings.HasPrefix(arg, ".") || filepath.IsAbs(arg) {
246242
retArgs = append(retArgs, arg)
247243
} else {
248-
println("ELSE", arg)
249244
// go/packages doesn't work well if we don't have the prefix ./ for local packages
250245
retArgs = append(retArgs, fmt.Sprintf(".%c%s", filepath.Separator, arg))
251246
}

pkg/lint/package_test.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/stretchr/testify/assert"
8+
"github.com/stretchr/testify/require"
89
)
910

1011
func Test_buildArgs(t *testing.T) {
@@ -30,8 +31,8 @@ func Test_buildArgs(t *testing.T) {
3031
},
3132
{
3233
desc: "absolute path",
33-
args: []string{filepath.FromSlash("/tmp/foo")},
34-
expected: []string{filepath.FromSlash("/tmp/foo")},
34+
args: []string{mustAbs(t, "/tmp/foo")},
35+
expected: []string{mustAbs(t, "/tmp/foo")},
3536
},
3637
}
3738

@@ -46,3 +47,12 @@ func Test_buildArgs(t *testing.T) {
4647
})
4748
}
4849
}
50+
51+
func mustAbs(t *testing.T, p string) string {
52+
t.Helper()
53+
54+
abs, err := filepath.Abs(filepath.FromSlash(p))
55+
require.NoError(t, err)
56+
57+
return abs
58+
}

0 commit comments

Comments
 (0)