github.com/traefik/yaegi@v0.15.1/_test/file_access.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 ) 7 8 func main() { 9 file, err := os.CreateTemp("", "yeagibench") 10 if err != nil { 11 panic(err) 12 } 13 14 n, err := file.Write([]byte("hello world")) 15 if err != nil { 16 panic(err) 17 } 18 fmt.Println("n:", n) 19 20 err = file.Close() 21 if err != nil { 22 panic(err) 23 } 24 25 b, err := os.ReadFile(file.Name()) 26 if err != nil { 27 panic(err) 28 } 29 fmt.Println("b:", string(b)) 30 31 err = os.Remove(file.Name()) 32 if err != nil { 33 panic(err) 34 } 35 } 36 37 // Output: 38 // n: 11 39 // b: hello world