@cryptotaxi247 / kubo / commits / 3eafb3e5a

style(repo): repo.Interface -> repo.Repo

The pkg.Interface style is modeled after heap.Interface. Generally, I find it helpful for interfaces that have many implementations. It provides clear distinction between the generic interface and the |n| implementations that implement it (which may be interface types themselves). For clients who cannot keep the repo name, one can imagine that the most likely rename is `ipfsrepo`. In that case, `ipfsrepo.Interface` remains meaningful. This is low-pri so it doesn't matter than much. But for the record, the repo.Interface feels appropriate in this use-case.

Brian Tiger Chow committed Jan 13, 2015 at 02:52 UTC 3eafb3e5ab8ada47be8104407b1e65fd65b91dcf
4 files changed +7 -7
core/commands/bootstrap.go
+3 -3
@@ -228,7 +228,7 @@ func bootstrapWritePeers(w io.Writer, prefix string, peers []config.BootstrapPee
228 return nil
229 }
230
231 -func bootstrapAdd(r repo.Interface, cfg *config.Config, peers []config.BootstrapPeer) ([]config.BootstrapPeer, error) {
231 +func bootstrapAdd(r repo.Repo, cfg *config.Config, peers []config.BootstrapPeer) ([]config.BootstrapPeer, error) {
232 added := make([]config.BootstrapPeer, 0, len(peers))
233
234 for _, peer := range peers {
@@ -253,7 +253,7 @@ func bootstrapAdd(r repo.Interface, cfg *config.Config, peers []config.Bootstrap
253 return added, nil
254 }
255
256 -func bootstrapRemove(r repo.Interface, cfg *config.Config, toRemove []config.BootstrapPeer) ([]config.BootstrapPeer, error) {
256 +func bootstrapRemove(r repo.Repo, cfg *config.Config, toRemove []config.BootstrapPeer) ([]config.BootstrapPeer, error) {
257 removed := make([]config.BootstrapPeer, 0, len(toRemove))
258 keep := make([]config.BootstrapPeer, 0, len(cfg.Bootstrap))
259
@@ -280,7 +280,7 @@ func bootstrapRemove(r repo.Interface, cfg *config.Config, toRemove []config.Boo
280 return removed, nil
281 }
282
283 -func bootstrapRemoveAll(r repo.Interface, cfg *config.Config) ([]config.BootstrapPeer, error) {
283 +func bootstrapRemoveAll(r repo.Repo, cfg *config.Config) ([]config.BootstrapPeer, error) {
284 removed := make([]config.BootstrapPeer, len(cfg.Bootstrap))
285 copy(removed, cfg.Bootstrap)
286
core/commands/config.go
+2 -2
@@ -143,7 +143,7 @@ variable set to your preferred text editor.
143 },
144 }
145
146 -func getConfig(r repo.Interface, key string) (*ConfigField, error) {
146 +func getConfig(r repo.Repo, key string) (*ConfigField, error) {
147 value, err := r.GetConfigKey(key)
148 if err != nil {
149 return nil, fmt.Errorf("Failed to get config value: %s", err)
@@ -154,7 +154,7 @@ func getConfig(r repo.Interface, key string) (*ConfigField, error) {
154 }, nil
155 }
156
157 -func setConfig(r repo.Interface, key, value string) (*ConfigField, error) {
157 +func setConfig(r repo.Repo, key, value string) (*ConfigField, error) {
158 err := r.SetConfigKey(key, value)
159 if err != nil {
160 return nil, fmt.Errorf("Failed to set config value: %s", err)
repo/fsrepo/fsrepo.go
+1 -1
@@ -222,7 +222,7 @@ func (r *FSRepo) Close() error {
222 }
223
224 var _ io.Closer = &FSRepo{}
225 -var _ repo.Interface = &FSRepo{}
225 +var _ repo.Repo = &FSRepo{}
226
227 // IsInitialized returns true if the repo is initialized at provided |path|.
228 func IsInitialized(path string) bool {
repo/repo.go
+1 -1
@@ -5,7 +5,7 @@ import (
5 util "github.com/jbenet/go-ipfs/util"
6 )
7
8 -type Interface interface {
8 +type Repo interface {
9 Config() *config.Config
10 SetConfig(*config.Config) error
11