|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/afero"
|
|
)
|
|
|
|
func main() {
|
|
//基于内存的文件读写
|
|
fs := afero.NewMemMapFs()
|
|
|
|
afero.WriteFile(fs, "poem.txt", []byte("月光光,照大床"), 0644)
|
|
|
|
data, err := afero.ReadFile(fs, "poem.txt")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
fmt.Println(string(data))
|
|
}
|