mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
Merge branch 'stek29-default_gopath'
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -105,11 +103,6 @@ func (p *Parser) Parse(fname string, isDir bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getDefaultGoPath() (string, error) {
|
||||
output, err := exec.Command("go", "env", "GOPATH").Output()
|
||||
return string(bytes.TrimSpace(output)), err
|
||||
}
|
||||
|
||||
func excludeTestFiles(fi os.FileInfo) bool {
|
||||
return !strings.HasSuffix(fi.Name(), "_test.go")
|
||||
}
|
||||
|
||||
+2
-5
@@ -3,6 +3,7 @@ package parser
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -121,11 +122,7 @@ func getModulePath(goModPath string) string {
|
||||
func getPkgPathFromGOPATH(fname string, isDir bool) (string, error) {
|
||||
gopath := os.Getenv("GOPATH")
|
||||
if gopath == "" {
|
||||
var err error
|
||||
gopath, err = getDefaultGoPath()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot determine GOPATH: %s", err)
|
||||
}
|
||||
gopath = build.Default.GOPATH
|
||||
}
|
||||
|
||||
for _, p := range strings.Split(gopath, string(filepath.ListSeparator)) {
|
||||
|
||||
Reference in New Issue
Block a user