diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-08 11:45:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-08 11:45:07 +0100 |
commit | b65d94e70ea1d013f43234522fa092168e4f1041 (patch) | |
tree | b36da73bd512d1b0ac52e4174ed8b7ed22c75b25 /utils/ioutil/common.go | |
parent | 431af32445562b389397f3ee7af90bf61455fff1 (diff) | |
parent | 84b6bd8c22c8683479881a67db03dfdeeeb299ce (diff) | |
download | go-git-b65d94e70ea1d013f43234522fa092168e4f1041.tar.gz |
Merge pull request #259 from smola/docs
Improve documentation
Diffstat (limited to 'utils/ioutil/common.go')
-rw-r--r-- | utils/ioutil/common.go | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/utils/ioutil/common.go b/utils/ioutil/common.go index a847abd..73cc9c3 100644 --- a/utils/ioutil/common.go +++ b/utils/ioutil/common.go @@ -1,3 +1,4 @@ +// Package ioutil implements some I/O utility functions. package ioutil import ( @@ -63,20 +64,9 @@ func WriteNopCloser(w io.Writer) io.WriteCloser { return writeNopCloser{w} } -// CheckClose is used with defer to close the given io.Closer and check its -// returned error value. If Close returns an error and the given *error -// is not nil, *error is set to the error returned by Close. -// -// CheckClose is typically used with named return values like so: -// -// func do(obj *Object) (err error) { -// w, err := obj.Writer() -// if err != nil { -// return nil -// } -// defer CheckClose(w, &err) -// // work with w -// } +// CheckClose calls Close on the given io.Closer. If the given *error points to +// nil, it will be assigned the error returned by Close. Otherwise, any error +// returned by Close will be ignored. CheckClose is usually called with defer. func CheckClose(c io.Closer, err *error) { if cerr := c.Close(); cerr != nil && *err == nil { *err = cerr |