Avoid deprecated LoadModes packages.{LoadFiles, LoadSyntax} (#116)
From the docs for packages.{LoadFiles, LoadSyntax} - https://godoc.org/golang.org/x/tools/go/packages#pkg-constants // Deprecated: LoadFiles exists for historical compatibility // and should not be used. Please directly specify the needed // fields using the Need values. // ... // Deprecated: LoadSyntax exists for historical compatibility // and should not be used. Please directly specify the needed // fields using the Need values.
This commit is contained in:
parent
75d0ddfc00
commit
8f50fb6793
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,3 +23,4 @@ _testmain.go
|
|||||||
*.test
|
*.test
|
||||||
*.prof
|
*.prof
|
||||||
.vscode
|
.vscode
|
||||||
|
.idea
|
||||||
|
@ -71,7 +71,7 @@ type Mocker struct {
|
|||||||
|
|
||||||
// New makes a new Mocker for the specified package directory.
|
// New makes a new Mocker for the specified package directory.
|
||||||
func New(src, packageName string) (*Mocker, error) {
|
func New(src, packageName string) (*Mocker, error) {
|
||||||
srcPkg, err := pkgInfoFromPath(src, packages.LoadSyntax)
|
srcPkg, err := pkgInfoFromPath(src, packages.NeedName|packages.NeedTypes|packages.NeedTypesInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("couldn't load source package: %s", err)
|
return nil, fmt.Errorf("couldn't load source package: %s", err)
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ func findPkgPath(pkgInputVal string, srcPkg *packages.Package) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func pkgInDir(pkgName, dir string) bool {
|
func pkgInDir(pkgName, dir string) bool {
|
||||||
currentPkg, err := pkgInfoFromPath(dir, packages.LoadFiles)
|
currentPkg, err := pkgInfoFromPath(dir, packages.NeedName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user