files
import (
"fmt"
"io"
"os"
"io/ioutil"
"path/filepath"
)Basics
Writing
func main() {
file, err := os.Create("./fromString.txt") //ptr to file that doesn't/might not exist yet
checkError(err)
defer file.Close()
ln, err := io.WriteString(file, "Hello there")
checkError(err)
fmt.Printf("%v characters", ln)
}
func checkError(err error) {
if err != nil {
panic(err) //cause stop and display err
}
}Bytes
Reading
Dirs
Sample Walk
Last updated