Last active
September 13, 2017 18:16
-
-
Save vladimirvivien/8f08dc956e282a8892672d7704ea2731 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 main() { | |
proverbs := new(bytes.Buffer) | |
proverbs.WriteString("Channels orchestrate mutexes serialize\n") | |
proverbs.WriteString("Cgo is not Go\n") | |
proverbs.WriteString("Errors are values\n") | |
proverbs.WriteString("Don't panic\n") | |
file, err := os.Create("./proverbs.txt") | |
if err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
defer file.Close() | |
// copy from reader data into writer file | |
if _, err := io.Copy(file, proverbs); err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
fmt.Println("file created") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment