-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
String function is not viable in environments where executable go
is unavailable
#18
Comments
👋 hey! Nice to hear from you! :( bummer, this is definitely unintentional. I didn’t think we depended on the go binary at all. I think that what may be happening is our usage of gofumpt has brought this in by accident: https://github.com/hexops/valast/blob/main/valast.go#L113 |
Heya! 😀 Sorry that it's via an issue report! 😅
Thanks for confirming.
From what I can tell, this particular dependence on the |
go
is unavailablego
is unavailable
Ahhh, that makes more sense. For context, through reflection we are able to get a types’ package import path - but we aren’t sure how we should refer to it canonically in code (import path != name, as you know) so that is what DefaultPackagePathToName is doing. I wonder what go-spew and go-goon do in this case? I guess your original comment about using a different default implementation under ‘ GOOS=js GOARCH=wasm’ may be the right path forward! |
Consider the following (minified) example program that tries to print a value of type
font.Metrics
:(https://play.golang.org/p/6nQBdwaHo5q)
It prints:
When executed in an environment where an executable
go
is unavailable, such as inside a browser via WebAssembly (GOOS=js GOARCH=wasm
), or inside the Go Playground.It's possible to provide a custom
PackagePathToName
function via an option, such as:Then it doesn't get the aforementioned error.
Is this intended behavior for
String
, or shouldvalast
know thatGOOS=js GOARCH=wasm
environment cannot execute ago
binary and should automatically use a differentPackagePathToName
implementation, so that it's possible to useString
?Note that both
spew.Dump(face.Metrics())
andgoon.Dump(face.Metrics())
print an output without an error inside a browser.The text was updated successfully, but these errors were encountered: