Skip to content
Myr

Fixed import path issue on Windows

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jared Bydeley · committed by Steve Francia · parent 29cddf6 · Browse files · 2 files+12 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+12 added−9 removed

  • other:+12 added−9 removed

2 files+12 added−9 removed

modified:cobra/cmd/helpers_test.go+11 added-8 removed
1 unmodified line
23import (4 "fmt"5 "os"6 "path/filepath"7 "testing"8)910var _ = fmt.Println
17 unmodified lines
28 projectPath = ""29}3031func TestProjectPath(t *testing.T) {31 checkGuess(t, "", "github.com/spf13/hugo", getSrcPath()+"github.com/spf13/hugo")32 checkGuess(t, "", "spf13/hugo", getSrcPath()+"github.com/spf13/hugo")33 checkGuess(t, "", "/bar/foo", "/bar/foo")34 checkGuess(t, "/bar/foo", "baz", "/bar/foo/baz")35 checkGuess(t, "/bar/foo/cmd", "", "/bar/foo")36 checkGuess(t, "/bar/foo/command", "", "/bar/foo")37 checkGuess(t, "/bar/foo/commands", "", "/bar/foo")38 checkGuess(t, "github.com/spf13/hugo/../hugo", "", "github.com/spf13/hugo")32 wd, _ := os.Getwd()3334 checkGuess(t, "", "github.com/spf13/hugo", filepath.Join(wd, "github.com", "spf13", "hugo"))35 checkGuess(t, "", "spf13/hugo", filepath.Join(wd, "spf13", "hugo"))36 checkGuess(t, "", "/bar/foo", filepath.Join(wd, "bar", "foo"))37 checkGuess(t, "/bar/foo", "baz", filepath.Join("/", "bar", "foo", "baz"))38 checkGuess(t, "/bar/foo/cmd", "", filepath.Join("/", "bar", "foo"))39 checkGuess(t, "/bar/foo/command", "", filepath.Join("/", "bar", "foo"))40 checkGuess(t, "/bar/foo/commands", "", filepath.Join("/", "bar", "foo"))41 checkGuess(t, "github.com/spf13/hugo/../hugo", "", filepath.Join("github.com", "spf13", "hugo"))42}
modified:cobra/cmd/helpers.go+1 added-1 removed
102 unmodified lines
103 if !strings.HasPrefix(projectPath, getSrcPath()) {104 er("Cobra only supports project within $GOPATH")105 }106107 return filepath.Clean(strings.TrimPrefix(projectPath, getSrcPath()))107 return filepath.ToSlash(filepath.Clean(strings.TrimPrefix(projectPath, getSrcPath())))108}109110func getSrcPath() string {111 return filepath.Join(os.Getenv("GOPATH"), "src") + string(os.PathSeparator)
236 unmodified lines