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

fix interfaces so they work in a nicer go style #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

whyrusleeping
Copy link
Member

This PR makes the go-multiaddr interface match my own views on how interfaces in go should work, namely:

  1. Constructors should always return a concrete type, not an interface.
  • this means that no extra casting is required to expose extra capabilities of the underlying type. While its not a big deal for the multiaddr type, take a look at the go-datastore package for why this one matters.

And

  1. Interface methods should never contain references to the type in question (or really any other types from within the same package)
  • this ensures that the same interface imported from two differently vendored packages implement eachother

@whyrusleeping
Copy link
Member Author

this isnt finished yet as the interface still references the Protocols type. The optimal fix (i think) for that is to move the protocols into their own package. (what? go gets better with increased modularity?)

@jbenet
Copy link
Member

jbenet commented Mar 16, 2016

great, this LGTM. this will be a breaking change.

great observations @whyrusleeping

@whyrusleeping
Copy link
Member Author

@jbenet thoughts on making a go-multiaddr-protocols repo? if we do that, and merge this PR after, we should solve a lot of the 'different import path' issues we've been having.

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

Successfully merging this pull request may close these issues.

None yet

2 participants