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

Golint-ify unixfs module #4664

Merged
merged 10 commits into from
Feb 7, 2018
Merged

Golint-ify unixfs module #4664

merged 10 commits into from
Feb 7, 2018

Conversation

hsanjuan
Copy link
Contributor

@hsanjuan hsanjuan commented Feb 6, 2018

This resolves all golint warnings in unixfs. hamt.HamtShard has been renamed to hamt.Shard to remove stuttering.

Note that protobuf generated files are not golint compliant, but haven't touched those.

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
Note, stuttering required renaming of HamtShard to Shard.

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
@ghost ghost assigned hsanjuan Feb 6, 2018
@ghost ghost added the status/in-progress In progress label Feb 6, 2018
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM.

@@ -157,6 +162,9 @@ func (d *Directory) Links(ctx context.Context) ([]*ipld.Link, error) {
return d.shard.EnumLinks(ctx)
}

// Find returns the ipld.Node with the given name, if it is contained in this
// directory. Find only searches in the most inmediate links, and not
// recursively in the tree.
func (d *Directory) Find(ctx context.Context, name string) (ipld.Node, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Find returns the root node of the file named name within this directory (really, it should be called Lookup). It does, in fact, traverse the tree (when searching a hamt).

var (
ErrSeekFail = errors.New("failed to seek properly")
ErrUnrecognizedWhence = errors.New("unrecognized whence")
ErrNotUnixfs = fmt.Errorf("dagmodifier only supports unixfs nodes (proto or raw)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well be consistent and use the errors package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of scope I'd say

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yeah, got it now

func NewBufDagReader(b []byte) *bufDagReader {
// newBufDagReader returns a DAG reader for the given byte slice.
// BufDagReader is used to read RawNodes.
func newBufDagReader(b []byte) *bufDagReader {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just make bufDatReader public.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So between increasing the API surface and decreasing it, I went with the latter (since this method is not used by anyone). But I'll make it public then...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but you exposed the PBDagReader so I figured we should be consistent at least.

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
per @Stebalien's comment

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

// A DagReader represents a ReadSeekCloser which offers additional methods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

represents a ReadSeekCloser which offers additional methods

This doesnt really get at what the dagreader does. I would say something more like:

// A DagReader provides read-only read and seek acess to a unixfs file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

type DagReader interface {
ReadSeekCloser
Size() uint64
CtxReadFull(context.Context, []byte) (int, error)
Offset() int64
}

// A ReadSeekCloser implements interfaces to read, write, seek and close.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'write' doesnt belong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, more copy

Copy link
Member

@whyrusleeping whyrusleeping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! just a couple small nitpicks, then LGTM

Per @whys suggestions

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
@hsanjuan
Copy link
Contributor Author

hsanjuan commented Feb 7, 2018

all comments addressed

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

@whyrusleeping whyrusleeping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woooo!

@whyrusleeping whyrusleeping merged commit 95daef4 into master Feb 7, 2018
@ghost ghost removed the status/in-progress In progress label Feb 7, 2018
@whyrusleeping whyrusleeping deleted the doc/golint-unixfs branch February 7, 2018 20:48
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.

4 participants