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: provide function to enumerate valid target combinations #47790

Open
mcandre opened this issue Aug 18, 2021 · 5 comments
Open

go/build: provide function to enumerate valid target combinations #47790

mcandre opened this issue Aug 18, 2021 · 5 comments
Labels
FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mcandre
Copy link

mcandre commented Aug 18, 2021

Please provide a reliable function to dynamically query the list of valid (GOOS, GOARCH) combinations, so that application maintainers can plug directly into this system and build as many ports as possible.

Certain workarounds have limitations:

This could all be streamlined with a first party API. An array of combination strings would be nice. Or a hashmap of valid combination strings, which could serve for both enumeration and efficient validation, acting logically as a mathematical set for existence / non-existence checks.

@cespare
Copy link
Contributor

cespare commented Aug 18, 2021

Use go tool dist list or go tool dist list -json.

@cespare cespare closed this as completed Aug 18, 2021
@cespare
Copy link
Contributor

cespare commented Aug 18, 2021

(See context at #12270.)

Actually, I'll leave this open since you specifically asked for a Go API. But I think the answer will probably be to use go tool dist.

@cespare cespare reopened this Aug 18, 2021
@mknyszek mknyszek changed the title Provide std lib function to enumerate valid target combinations go/build: provide function to enumerate valid target combinations Aug 18, 2021
@mknyszek
Copy link
Contributor

mknyszek commented Aug 18, 2021

I'm not even sure which package this would go in, but I took a guess. Feel free to update the title if you have a better idea.

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 18, 2021
@mknyszek mknyszek added this to the Backlog milestone Aug 18, 2021
@mknyszek
Copy link
Contributor

mknyszek commented Aug 18, 2021

CC @rsc I guess?

@mcandre
Copy link
Author

mcandre commented Aug 18, 2021

@cespare Yes, an API would be more efficient than a shell command.

I do appreciate the tip. I can use go tool dist list meanwhile as a workaround for a leaner mechanism.

I am planning on wrapping go tool dist list into a reusable tool for building as many ports as possible.

https://github.com/mcandre/factorio

Works similar to the venerable gox utility, but with simpler options. Mostly pass-through.

Now that the platform metadata comes dynamically from the real go command line tool, hopefully the data doesn't have to be manually updated as often. The intention is for the same factorio code to work with future Go releases, as the language continues to add (unanticipated) targets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants