Files with os
os.WriteFile and os.ReadFile handle small files quickly.
Example
package main
import (
"fmt"
"os"
)
func main() {
p := os.TempDir() + "/demo.txt"
os.WriteFile(p, []byte("hi\n"), 0644)
b, _ := os.ReadFile(p)
fmt.Print(string(b))
os.Remove(p)
}Result
hi
Exercise
Read a file.
os.(p)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.