Open ayang64 opened 3 years ago
/cc @rsc
Workaround is to invoke it with -base
, but that is obviously far from ideal.
present -base ~/go/src/golang.org/x/tools/cmd/present
@mikijov -- thank you for that work-around! i think part of my issue is that go 1.16 doesn't place the source for package in an easy to find location. for example, when i use go get
, the static files land in ${GOPATH}/pkg/mod/golang.org/x/tools@v0.0.0-20210115202250-e0d201561e39/cmd/present
.
so this patch is meant to simplify things by embedding all of the static files.
x/tools
(and any other module wanting to support Go versions before 1.16) cannot make use of the embed
package due to #40067; if you want to embed the assets, you'd need to do it by other means.
EDIT: The restriction is any package in x/tools
(my mistake); if you don't import it you don't see the error, but it would make present
not possible to use even with build tags.
x/tools
(and any other module wanting to support Go versions before 1.16) cannot make use of theembed
package due to #40067; if you want to embed the assets, you'd need to do it by other means.
I understand. So should I simply close this PR and the related issues?
The PR/CL maybe, but I wouldn't personally be closing the issues as you're still getting them. This is certainly still an issue; it's just that the fix can't be the embed
package unless #40067 is fixed and backported to old versions of Go (or, we wait a couple of years).
FWIW, my original reasoning here was wrong (sorry 😦); embed
could be used in a package like this as it's not importable (so the go tooling was happy before); just note that this would still have to wait for x/tools/cmd/present
to no longer need to be supported for anything below 1.16.
I updated from golang v1.14 to 1.16 and thought things will work the same (or better), but this is sad exception. Before it was working perfectly, now by default it fails miserably and one need to search internet and only on internal bugtracker it's possible to find explanation what's happening. How can this change/workaround not be explained in the present docs? Sorry for my tone, but such user unfriendliness is incredible.
What worked for me was present -base ~/go/pkg/mod/golang.org/x/tools@v0.1.0/cmd/present
- maybe at least add this as a suggestion in cmdline output.
Instead of using -base
flag you could turn off modules temporarily with GO111MODULE=off present
. Starting this way it will run as espected as of now.
Change https://golang.org/cl/356290 mentions this issue: cmd/present: embed contents when available
What version of Go are you using (
go version
)?go 1.16
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I installed the present tool using go get:
That error occurs because go didn't place the source for the present tool in my $GOPATH.
What did you expect to see?
What did you see instead?
I believe the right thing to do is to embed the static assets and templates in the present tool. I submitted a PR that appears to work at:
https://github.com/golang/tools/pull/264