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

'go build -trimpath' (from Go 1.13+) breaks AST parsing #4

Open
meowsbits opened this issue Nov 12, 2020 · 2 comments
Open

'go build -trimpath' (from Go 1.13+) breaks AST parsing #4

meowsbits opened this issue Nov 12, 2020 · 2 comments

Comments

@meowsbits
Copy link
Contributor

Re: go build -trimpath https://golang.org/doc/go1.13#go-command

This flag reduces the size of the binary and "improves privacy" by stripping the machine-specific paths. However, stripping path information causes the AST traversal required by OpenRPC to fail because runtime.FileLine is unable to provide an absolute path, resulting in file not found errors.

So far, my thinking is that it can be worked around by creating basically an environment variable that etclabscore/go-openrpc-reflect would fall back to in case its AST steps error with "file not found." I'm not sure if there's a way to corroborate that failure at build time with a check against the go build flags, but would be nice.

@yihuang
Copy link

yihuang commented Apr 21, 2022

I think we can provide an option to generate the file offline, and embed it manually with go:embed.

@meowsbits
Copy link
Contributor Author

Oh, cool idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants