A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the File Input Output in Go page! Here, you'll find the source code for this program as well as a description of how the program works.
package main
import (
"fmt"
"io/ioutil"
"log"
)
func read() (string, error) {
contents, err := ioutil.ReadFile("output.txt")
return string(contents), err
}
func write(contents string) error {
return ioutil.WriteFile("output.txt", []byte(contents), 0644)
}
func main() {
err := write("file contents")
if err != nil {
log.Fatal(err)
}
contents, err := read()
if err != nil {
log.Fatal(err)
}
fmt.Println(contents)
}
File Input Output in Go was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.