12345678910111213141516171819 |
- package test
- import (
- "fmt"
- "io"
- "os"
- "testing"
- )
- func TestIO(t *testing.T) {
- //file, err := os.OpenFile("b.txt", os.O_RDONLY, 0)
- file, err := os.OpenFile("b.txt", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0)
- if err != nil {
- panic(err)
- }
- defer file.Close()
- contentBytes, err := io.ReadAll(file)
- fmt.Println(string(contentBytes))
- }
|