Skip to content

Commit e2752bc

Browse files
joaquinlpereyra-mlgcmurphy
authored andcommitted
revert to default GOPATH if necessary (#279)
* revert to default GOPATH if necessary
1 parent 04ce7ba commit e2752bc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

testutils/pkg.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ type TestPackage struct {
3131
// NewTestPackage will create a new and empty package. Must call Close() to cleanup
3232
// auxiliary files
3333
func NewTestPackage() *TestPackage {
34+
goPath := os.Getenv("GOPATH")
35+
// if user did not set GOPATH, set to the default
36+
if goPath == "" {
37+
goPath = build.Default.GOPATH
38+
}
39+
3440
// Files must exist in $GOPATH
35-
sourceDir := path.Join(os.Getenv("GOPATH"), "src")
41+
sourceDir := path.Join(goPath, "src")
3642
workingDir, err := ioutil.TempDir(sourceDir, "gosecs_test")
3743
if err != nil {
3844
return nil

0 commit comments

Comments
 (0)