Created
June 12, 2018 05:21
-
-
Save HauptJ/58e78219dd3e7a35a15c5c23bf828b9f to your computer and use it in GitHub Desktop.
Golang function to write a string to a file with overwrite
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
/* | |
DESC: writes to new file | |
IN: output file: outFile, string of contents to write: contents | |
OUT: nill on success | |
*/ | |
func write_file(outFile, contents string) error { | |
err := ioutil.WriteFile(outFile, []byte(contents), 0644) | |
if err != nil { | |
panic(err) | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment