-
Notifications
You must be signed in to change notification settings - Fork 18k
x/text/cmd/gotext: extract command crash if no messages #26312
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
Comments
Looks like this started with golang/text@2cb4393 "message/pipeline: use ssa and callgraph": Specifically on this line where there is no check whether @mpvl, I guess the question is: should the output be an error or blank? |
I've also hit this as I'm testing the library. IMO the executable should say that there is no translation strings to extract. func (me *LoginFormData) Validate(r *http.Request) error {
T := context.GetDataFromContext(r.Context()).Trans
_= T.Sprint("The email address you entered is not valid")) //TRANS:
return nil
} Will also fail with above error.. And I think this will be a common usecase |
FWIW I've started to dig deeper into this issue and this is what I found. I get this error when using vendored dependencies with e.g.
... is |
We are having the same issue with vendored dependencies:
Is it there a workaround? |
@msama In a similar case, adding |
Having the same issue when using a vendor folder. When the vendor folder is removed, it works. I just revendor afterwards for the moment. |
@fgm Hello, how to add |
@dragon9783 this little line is the code snippet: just add it at the top-level package of your library/command (the main package if it's a command)/ |
I still have the same issue, and |
I have solved the issue by running rm -rf vendor/golang.org/x/text command from the root of the project. Of course for things to work, I also needed to have gotext installed. This can be done by running go get golang.org/x/text/cmd/gotext. |
I believe the issue could be solved if binaries of |
What version of Go are you using (
go version
)?go1.9.2
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?windows/amd64
What did you do?
Run
gotext extract
command on a project directory without any messages to extract and nogolang.org/x/text/message
import.What did you expect to see?
A blank or error response.
What did you see instead?
A runtime error :
The text was updated successfully, but these errors were encountered: