New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: hangs with 100% CPU on import of absolute path #27474
Comments
Hi @bmeh , This appears to be a question rather than a Go bug. We do not use the issue tracker for general discussions or questions like these. The Github bug tracker is only used for tracking bugs and proposals going through the Proposal Process. You might want to take a look at Questions wiki page; it has a list of good places for asking questions. Therefore closing this issue. |
@myitcv Please take a look at the original post, I edited it a couple of days ago. I don't think it's supposed to hang indefinitely and eat 100% CPU seemingly doing nothing (see the last lines of Feel free to change the title of this issue accordingly if it indeed is a bug. |
@bmeh as you point out, relative import paths will not work. They might work with Using an absolute path for an import path is also undefined (although I agree it should fail more gracefully than simply hanging). I will retitle the issue for this bug. From the directory layout in your original description it looks like you want a |
go build -mod vendor
) with local packages? (help wanted)
On reflection @bmeh it's going to be a bit of work to re-edit your description in this issue, so I'll close this issue. Please can you open a new issue, completing the issue template, with details of the hang? Thanks |
In
main.go
:It works with
go build main.go
, but does not work withgo build -mod vendor main.go
because it says:Of course it tells me this because
go.mod
doesn't exist for main.go, so upon creating it throughgo mod init main
, it creates the file with onlymodule main
and no dependencies. This doesn't help though, because then it tells me this:even though
logger/go.mod
exists, and is correct.The thing is,
go build main.go
works, butgo build -mod vendor main.go
doesn't, so my question is, how do I make it work withgo build -mod vendor main.go
? Ideallymain.go
's dependency on./logger
should be inmain
'sgo.mod
, but it might not support "local" modules for all I know. I'm not exactly sure what's the proper way to use internal, library packages that are used only by this project. The reason I need it for is modularization. Some projects importgithub.com/user/project/foo/utils
,github.com/user/project/foo/logger
and so on, but usingimport "./logger"
seems to do fine for me, apart from not working well with vendoring. I also have read something about naming internal packagesinternal
, but I have not came across any usable, working examples (to be honest, I wasn't trying to find any hard enough :P). Any input and suggestions from "experts" would be greatly appreciated.Worth noting that
go build
alone will give me back this error:Not sure if this behavior is intended or not either.
Thank you for your help in advance!
Edit:
Changing the import path to the absolute path ("./logger" -> "/home/bmeh/foo/logger") makes
go
hung up and eat 100% CPU when usinggo build -mod vendor main.go
. No longer gives the aforementioned errors. I believe this is a bug. Please do correct me if I am wrong.Passing
-x
:The directory is empty.
Partial
strace
:and it just hangs indefinitely.
The text was updated successfully, but these errors were encountered: