-
-
Save bom-d-van/5509102 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cp | |
import ( | |
"io" | |
"os" | |
) | |
func cp(dst, src string) error { | |
s, err := os.Open(src) | |
if err != nil { | |
return err | |
} | |
// no need to check errors on read only file, we already got everything | |
// we need from the filesystem, so nothing can go wrong now. | |
defer s.Close() | |
d, err := os.Create(dst) | |
if err != nil { | |
return err | |
} | |
if _, err := io.Copy(d, s); err != nil { | |
d.Close() | |
return err | |
} | |
return d.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment