@cryptotaxi247 / kubo / commits / d7cd05916

Doc: golint: remove stuttering in pin package

License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>

Hector Sanjuan committed Feb 13, 2018 at 13:00 UTC d7cd0591651583bf3af47ebbee59596f44368cfd
2 files changed +19 -19
core/commands/pin.go
+1 -1
@@ -494,7 +494,7 @@ type RefKeyList struct {
494
495 func pinLsKeys(args []string, typeStr string, ctx context.Context, n *core.IpfsNode) (map[string]RefKeyObject, error) {
496
497 - mode, ok := pin.StringToPinMode(typeStr)
497 + mode, ok := pin.StringToMode(typeStr)
498 if !ok {
499 return nil, fmt.Errorf("invalid pin mode '%s'", typeStr)
500 }
pin/pin.go
+18 -18
@@ -43,14 +43,14 @@ const (
43 linkAll = "all"
44 )
45
46 -// PinMode allows to specify different types of pin (recursive, direct etc.).
46 +// Mode allows to specify different types of pin (recursive, direct etc.).
47 // See the Pin Modes constants for a full list.
48 -type PinMode int
48 +type Mode int
49
50 // Pin Modes
51 const (
52 // Recursive pins pin the target cids along with any reachable children.
53 - Recursive PinMode = iota
53 + Recursive Mode = iota
54
55 // Direct pins pin just the target cid.
56 Direct
@@ -68,9 +68,9 @@ const (
68 Any
69 )
70
71 -// PinModeToString returns a human-readable name for the PinMode.
72 -func PinModeToString(mode PinMode) (string, bool) {
73 - m := map[PinMode]string{
71 +// ModeToString returns a human-readable name for the Mode.
72 +func ModeToString(mode Mode) (string, bool) {
73 + m := map[Mode]string{
74 Recursive: linkRecursive,
75 Direct: linkDirect,
76 Indirect: linkIndirect,
@@ -82,10 +82,10 @@ func PinModeToString(mode PinMode) (string, bool) {
82 return s, ok
83 }
84
85 -// StringToPinMode parses the result of PinModeToString() back to a PinMode.
85 +// StringToMode parses the result of ModeToString() back to a Mode.
86 // It returns a boolean which is set to false if the mode is unknown.
87 -func StringToPinMode(s string) (PinMode, bool) {
88 - m := map[string]PinMode{
87 +func StringToMode(s string) (Mode, bool) {
88 + m := map[string]Mode{
89 linkRecursive: Recursive,
90 linkDirect: Direct,
91 linkIndirect: Indirect,
@@ -109,7 +109,7 @@ type Pinner interface {
109
110 // IsPinnedWithType returns whether or not the given cid is pinned with the
111 // given pin type, as well as returning the type of pin its pinned with.
112 - IsPinnedWithType(*cid.Cid, PinMode) (string, bool, error)
112 + IsPinnedWithType(*cid.Cid, Mode) (string, bool, error)
113
114 // Pin the given node, optionally recursively.
115 Pin(ctx context.Context, node ipld.Node, recursive bool) error
@@ -130,12 +130,12 @@ type Pinner interface {
130 // PinWithMode is for manually editing the pin structure. Use with
131 // care! If used improperly, garbage collection may not be
132 // successful.
133 - PinWithMode(*cid.Cid, PinMode)
133 + PinWithMode(*cid.Cid, Mode)
134
135 // RemovePinWithMode is for manually editing the pin structure.
136 // Use with care! If used improperly, garbage collection may not
137 // be successful.
138 - RemovePinWithMode(*cid.Cid, PinMode)
138 + RemovePinWithMode(*cid.Cid, Mode)
139
140 // Flush writes the pin state to the backing datastore
141 Flush() error
@@ -157,7 +157,7 @@ type Pinner interface {
157 // by some ascendant).
158 type Pinned struct {
159 Key *cid.Cid
160 - Mode PinMode
160 + Mode Mode
161 Via *cid.Cid
162 }
163
@@ -174,7 +174,7 @@ func (p Pinned) String() string {
174 case Indirect:
175 return fmt.Sprintf("pinned via %s", p.Via)
176 default:
177 - modeStr, _ := PinModeToString(p.Mode)
177 + modeStr, _ := ModeToString(p.Mode)
178 return fmt.Sprintf("pinned: %s", modeStr)
179 }
180 }
@@ -293,7 +293,7 @@ func (p *pinner) IsPinned(c *cid.Cid) (string, bool, error) {
293
294 // IsPinnedWithType returns whether or not the given cid is pinned with the
295 // given pin type, as well as returning the type of pin its pinned with.
296 -func (p *pinner) IsPinnedWithType(c *cid.Cid, mode PinMode) (string, bool, error) {
296 +func (p *pinner) IsPinnedWithType(c *cid.Cid, mode Mode) (string, bool, error) {
297 p.lock.RLock()
298 defer p.lock.RUnlock()
299 return p.isPinnedWithType(c, mode)
@@ -301,7 +301,7 @@ func (p *pinner) IsPinnedWithType(c *cid.Cid, mode PinMode) (string, bool, error
301
302 // isPinnedWithType is the implementation of IsPinnedWithType that does not lock.
303 // intended for use by other pinned methods that already take locks
304 -func (p *pinner) isPinnedWithType(c *cid.Cid, mode PinMode) (string, bool, error) {
304 +func (p *pinner) isPinnedWithType(c *cid.Cid, mode Mode) (string, bool, error) {
305 switch mode {
306 case Any, Direct, Indirect, Recursive, Internal:
307 default:
@@ -414,7 +414,7 @@ func (p *pinner) CheckIfPinned(cids ...*cid.Cid) ([]Pinned, error) {
414 // RemovePinWithMode is for manually editing the pin structure.
415 // Use with care! If used improperly, garbage collection may not
416 // be successful.
417 -func (p *pinner) RemovePinWithMode(c *cid.Cid, mode PinMode) {
417 +func (p *pinner) RemovePinWithMode(c *cid.Cid, mode Mode) {
418 p.lock.Lock()
419 defer p.lock.Unlock()
420 switch mode {
@@ -594,7 +594,7 @@ func (p *pinner) InternalPins() []*cid.Cid {
594
595 // PinWithMode allows the user to have fine grained control over pin
596 // counts
597 -func (p *pinner) PinWithMode(c *cid.Cid, mode PinMode) {
597 +func (p *pinner) PinWithMode(c *cid.Cid, mode Mode) {
598 p.lock.Lock()
599 defer p.lock.Unlock()
600 switch mode {