mirror of
https://github.com/securego/gosec.git
synced 2024-11-05 19:45:51 +00:00
revert to default GOPATH if necessary (#279)
* revert to default GOPATH if necessary
This commit is contained in:
parent
04ce7baf6c
commit
e2752bc191
1 changed files with 7 additions and 1 deletions
|
@ -31,8 +31,14 @@ type TestPackage struct {
|
|||
// NewTestPackage will create a new and empty package. Must call Close() to cleanup
|
||||
// auxiliary files
|
||||
func NewTestPackage() *TestPackage {
|
||||
goPath := os.Getenv("GOPATH")
|
||||
// if user did not set GOPATH, set to the default
|
||||
if goPath == "" {
|
||||
goPath = build.Default.GOPATH
|
||||
}
|
||||
|
||||
// Files must exist in $GOPATH
|
||||
sourceDir := path.Join(os.Getenv("GOPATH"), "src")
|
||||
sourceDir := path.Join(goPath, "src")
|
||||
workingDir, err := ioutil.TempDir(sourceDir, "gosecs_test")
|
||||
if err != nil {
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue