Created
April 14, 2017 07:53
-
-
Save aki237/fb0507b51e3f1bea41c5a06e1ec3dcc9 to your computer and use it in GitHub Desktop.
This file contains 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
func addParts(filename string, files []string) { | |
// filename : filename of full file. | |
// files : array of filenames of parts. | |
// Create if not found and open mode as append.. | |
// So writing means adding. | |
out, err := os.OpenFile(filename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) | |
// usual. | |
check err | |
// loop through `files` and write (add) it to the resulting file. | |
for _, val := range files { | |
f, err := os.Open(val) | |
check err | |
_, err = io.Copy(out, f) | |
check err | |
f.Close() | |
// Remove the temp file too... | |
os.Remove(val) | |
} | |
// Close the output file. | |
out.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment