Skip to content

infile: refactoring #174

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

Merged
merged 4 commits into from
Nov 16, 2013
Merged

infile: refactoring #174

merged 4 commits into from
Nov 16, 2013

Conversation

julienschmidt
Copy link
Member

No description provided.

data = make([]byte, 4+mc.maxWriteSize)

if rdc, ok := rdr.(io.ReadCloser); ok {
defer func() {
Copy link
Member

Choose a reason for hiding this comment

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

Considering it's also used below (line 112), I think we should introduce

func deferredClose(err *error, closer io.Closer) {
    closeErr := closer.Close()
    if *err == nil {
        *err = closeErr
    }
}

and use that for the defer. The function does not bind local vars, it gets passed a pointer. It's shorter and more general.

@arnehormann
Copy link
Member

LGTM after addressing comment

@julienschmidt
Copy link
Member Author

PTAL

@arnehormann
Copy link
Member

LGTM

julienschmidt added a commit that referenced this pull request Nov 16, 2013
@julienschmidt julienschmidt merged commit 5d25a76 into master Nov 16, 2013
@julienschmidt julienschmidt deleted the infile branch November 16, 2013 14:05
@julienschmidt julienschmidt added this to the v1.2 milestone Apr 1, 2014
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.

2 participants