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

Vendored Cobra is used in weave-blueprint #143

Open
felzix opened this issue Oct 10, 2018 · 0 comments
Open

Vendored Cobra is used in weave-blueprint #143

felzix opened this issue Oct 10, 2018 · 0 comments

Comments

@felzix
Copy link

felzix commented Oct 10, 2018

This might not count as an issue but it seems like a bad practice for a project designed to teach others how to use Loom.

I built a contract and now want to test it with a cli so I copied weave-blueprint's cli and edited to fit my contract. However, cli.ContractCallCommand() returns a cobra.Command from the vendored version of the "cobra" package. Since it's vendored, it can't be imported by anything outside of "go-loom", including by my package... I can't import "cobra" because that version and the vendored version are treated as completely different.

The only workaround I see is to copy-paste go-loom/cli/cli.go into my package and import that. This seems bad to me. I should be able to use library packages anywhere.

I don't think there should be any imports at all unless they're easy to use. Not for a tutorial. But if there are then they should be designed to be imported by newbie developers. This can be done (I think) by exporting a value that's just &cobra.Command or making a method that returns it. The "weave-blueprint" package should then use that exported value instead of importing "cobra" itself.

BTW I'm very not-confident here because my IDE sees the same problem with "weave-blueprint" as with my package. I assume building "weave-blueprint" would give me the same error as with my own package. Here's the error when I try to build my package's cli:

./cli.go:54:20: cannot use callCmd (type *"github.com/loomnetwork/go-loom/vendor/github.com/spf13/cobra".Command) as type *"github.com/spf13/cobra".Command in argument to rootCmd.AddCommand

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