Comments (4)
Because github.com/micro/go-micro is not managed by go mod, so when godef search in go-micro, it search in GOPATH (go env GOPATH).
So you can go get in GOPATH: go get github.com/micro/go-micro, and it fixed.
No, is not good idea. The depend package will download in GOPATH/pkg when I use go mod,So why do I download the package in GOPATH/src?
from godef.
Because github.com/micro/go-micro is not managed by go mod, so when godef search in go-micro, it search in GOPATH (go env GOPATH).
So you can go get in GOPATH: go get github.com/micro/go-micro, and it fixed.
from godef.
the DefaultImportPathToName will search one pkg in the srcDir(context where uses this pkg), to solve this, you can try to search in the rootDir(where to begin search) when DefaultImportPathToName fail.
func DefaultImportPathToName(path, srcDir string) (string, error) {
if path == "C" {
return "C", nil
}
pkg, err := build.Default.Import(path, srcDir, 0)
return pkg.Name, err
}
func DefaultImporter(path string, srcDir string) *ast.Package {
...
pkgs, err := parser.ParseDir(FileSet, bpkg.Dir, shouldInclude, 0, DefaultImportPathToName)
}
So, in DefaultImporter(), you can add a tryable ImportPathToName:
type TryableImportPathToName string
func (rootDir TryableImportPathToName) ImportPathToName(path, srcDir string) (string, error) {
pkgName, err := DefaultImportPathToName(path, srcDir)
if err == nil || srcDir == string(rootDir) {
return pkgName, err
}
return DefaultImportPathToName(path, string(rootDir))
}
func DefaultImporter(path string, srcDir string) *ast.Package {
...
pkgs, err := parser.ParseDir(FileSet, bpkg.Dir, shouldInclude, 0, TryableImportPathToName(srcDir).ImportPathToName)
}
from godef.
anyone looking forward to solve this with a PR ?
from godef.
Related Issues (20)
- Cannot find modules in $GOPATH/pkg/mod/cache/download
- godef might be extremly slow in Go packages using cgo when using go/packages
- godef by expression not working with go/packages HOT 3
- Allow a way to print the version of the godef tool
- Struct tips not pretty with go modules HOT 7
- go get github.com/rogpeppe/godef not working
- godef can't work for go while using import . ""
- godef takes ~2 seconds when used with go modules HOT 8
- godef can't work HOT 1
- When export GO111MODULE=on, the godef can not work. HOT 2
- internal error: nil Pkg importing "errors" from "mypkg" HOT 3
- godef: could not parse GOARCH and Go compiler HOT 2
- "no declaration found" when a package uses a binary literal
- include methods in members list HOT 1
- Godef fails in dependency module directories where no go.mod is present HOT 1
- Does godef support build tags?
- Printing the receiver for methods when printing types
- go mod project search github.com/coreos/etcd very slow and fail HOT 1
- Support showing variable initialization values when printing types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godef.