Supports using the default GOPATH
This commit is contained in:
parent
b3bb5c9e91
commit
65a386eae7
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/tockins/interact"
|
"github.com/tockins/interact"
|
||||||
|
"go/build"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"gopkg.in/urfave/cli.v2"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
@ -1126,10 +1127,13 @@ func before(*cli.Context) error {
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
log.SetOutput(logWriter{})
|
log.SetOutput(logWriter{})
|
||||||
// Before of every exec of a cli method
|
// Before of every exec of a cli method
|
||||||
gopath := os.Getenv("GOPATH")
|
gopath := build.Default.GOPATH
|
||||||
if gopath == "" {
|
if gopath == "" {
|
||||||
return errors.New("$GOPATH isn't set properly")
|
return errors.New("$GOPATH isn't set properly")
|
||||||
}
|
}
|
||||||
|
if err := os.Setenv("GOPATH", gopath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
// new realize instance
|
// new realize instance
|
||||||
r = new()
|
r = new()
|
||||||
// read if exist
|
// read if exist
|
||||||
|
|
Loading…
Reference in New Issue