Skip to content
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

x/text: "gotext extract" command crash if no messages #26312

Chocanto opened this issue Jul 10, 2018 · 11 comments

x/text: "gotext extract" command crash if no messages #26312

Chocanto opened this issue Jul 10, 2018 · 11 comments


Copy link

@Chocanto Chocanto commented Jul 10, 2018

What version of Go are you using (go version)?


Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?


What did you do?

Run gotext extract command on a project directory without any messages to extract and no import.

What did you expect to see?

A blank or error response.

What did you see instead?

A runtime error :

>gotext extract
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x866423]

goroutine 1 [running]:*extracter).seedEndpoints(0xc0421c6000)
        C:/GO-projects/src/ +0x63, 0x1, 0x1, 0x0)
        C:/GO-projects/src/ +0x5c
main.runExtract(0xd6c4c0, 0xc0420dc750, 0xc042046390, 0x0, 0x0, 0x0, 0x0)
        C:/GO-projects/src/ +0x63
        C:/GO-projects/src/ +0x34e
@gopherbot gopherbot added this to the Unreleased milestone Jul 10, 2018
Copy link

@meirf meirf commented Jul 16, 2018

Looks like this started with golang/text@2cb4393 "message/pipeline: use ssa and callgraph":

Specifically on this line where there is no check whether Program.Package's returned PackageInfo is nil.

@mpvl, I guess the question is: should the output be an error or blank?

Copy link

@mvrhov mvrhov commented Jul 21, 2018

I've also hit this as I'm testing the library. IMO the executable should say that there is no translation strings to extract.
However I'd say that the extract command doesn't work per se.

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

Copy link

@olivere olivere commented Sep 6, 2018

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. dep. The reasons seems to be that the x.iprog.Package("") in ...

pkg := x.prog.Package(x.iprog.Package("").Pkg)

... is nil because the x.iprog *ssa.Program will only find the vendored dependency (e.g. but not

Copy link

@msama msama commented Nov 21, 2018

We are having the same issue with vendored dependencies:

gotext: extract failed: pipeline: is not imported

Is it there a workaround?

Copy link

@fgm fgm commented Dec 13, 2018

@msama In a similar case, adding import _ "" at the top-level import fixed the issue for me

Copy link

@adlecluse adlecluse commented Jan 3, 2019

Having the same issue when using a vendor folder. When the vendor folder is removed, it works. I just revendor afterwards for the moment.

Copy link

@dragon9783 dragon9783 commented Feb 21, 2019

@fgm Hello, how to add import _ " at the top-level import? Can you share some code snippet?

Copy link

@fgm fgm commented Feb 21, 2019

@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)/

Copy link

@roman-popenov-zz roman-popenov-zz commented Jul 26, 2019

I still have the same issue, and import _ " at the top-level import doesn't seem to solve it.

Copy link

@roman-popenov-zz roman-popenov-zz commented Jul 26, 2019

I have solved the issue by running rm -rf vendor/ 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

Copy link

@roman-popenov-zz roman-popenov-zz commented Jul 26, 2019

I believe the issue could be solved if binaries of text/message are installed in the GOPATH/bin as well

@ALTree ALTree added the NeedsInvestigation label Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests