Description
Code generated by the following (semi-pseudo) example does not compile:
code := jen.NewFilePathName("path/to/pkg", "pkg_test")
code.ImportName("path/to/pkg", "pkg")
code.Qual("path/to/pkg", "MyStruct")
The problem is that the generated code in pkg_test
will not properly be qualified with the package import (path/to/pkg
), because the package path is actually the same. In my use case adding a _test
suffix to the file package path solved the issue, but it doesn't feel right. (What if I actually have a pkg_test
package?)
Not sure what the best solution would be here. Maybe handle _test
suffixes? (The problem is that technically you can have other package suffixes in a single package, if you manually pass those files to go tool compile
, but I think a special case for _test
suffixes would suffice for the time being.)
(Sorry for the dummy example, but I think it demonstrates the issue)
Activity