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

Parse should take a func instead of a map to query object file paths #13

Closed
mvdan opened this issue Sep 24, 2020 · 1 comment
Closed

Comments

@mvdan
Copy link
Contributor

mvdan commented Sep 24, 2020

That is, instead of:

func Parse(objPath, pkgPath string, importCfg ImportCfg) (*Package, error)

just:

func Parse(objPath, pkgPath string, importMap func(importPath string) (objectPath string)) (*Package, error)

Reasons to do so:

  1. It can be implemented in more ways. For example, right now in garble we have a map[string]importedPkg which also contains the object path, but since it's not a map[string]ExportInfo, I can't reuse it. I'd need two maps with the same keys, which is not ideal.
  2. It doesn't require having all the paths in memory upfront in a map. For example, we could fill a map as we go, memoizing previous queries.
@mvdan
Copy link
Contributor Author

mvdan commented Sep 24, 2020

If you want to keep the func signature short, it would always be possible to do type ImportMap = func(importPath string) (objectPath string) and then importMap ImportMap.

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

1 participant