2017-11-23 10:21:28 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-04-03 00:03:46 +08:00
|
|
|
"fmt"
|
2019-07-29 21:01:19 +08:00
|
|
|
|
|
|
|
"github.com/gogf/gf/os/gfile"
|
|
|
|
"github.com/gogf/gf/util/gutil"
|
2017-11-23 10:21:28 +08:00
|
|
|
)
|
|
|
|
|
2019-04-03 00:03:46 +08:00
|
|
|
var dirpath1 = "/home/john/Workspace/temp/"
|
|
|
|
var dirpath2 = "/home/john/Workspace/temp/1"
|
2017-11-23 10:21:28 +08:00
|
|
|
var filepath1 = "/home/john/Workspace/temp/test.php"
|
|
|
|
var filepath2 = "/tmp/tmp.test"
|
|
|
|
|
2019-04-03 00:03:46 +08:00
|
|
|
type BinData struct {
|
|
|
|
name string
|
|
|
|
age int
|
2017-11-23 10:21:28 +08:00
|
|
|
}
|
|
|
|
|
2019-04-03 00:03:46 +08:00
|
|
|
func info() {
|
|
|
|
fmt.Println(gfile.Info(dirpath1))
|
2017-11-23 10:21:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func scanDir() {
|
2019-04-03 00:03:46 +08:00
|
|
|
gutil.Dump(gfile.ScanDir(dirpath1, "*"))
|
2017-11-23 10:21:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func getContents() {
|
2019-04-03 00:03:46 +08:00
|
|
|
fmt.Printf("%s\n", gfile.GetContents(filepath1))
|
2017-11-23 10:21:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func putContents() {
|
2019-04-03 00:03:46 +08:00
|
|
|
fmt.Println(gfile.PutContentsAppend(filepath2, "123"))
|
2017-11-23 10:21:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func putBinContents() {
|
2019-09-06 16:59:38 +08:00
|
|
|
fmt.Println(gfile.PutBytes(filepath2, []byte("abc")))
|
2017-11-23 10:21:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2019-04-03 00:03:46 +08:00
|
|
|
//info()
|
|
|
|
//getContents()
|
|
|
|
//putContents()
|
|
|
|
putBinContents()
|
|
|
|
//scanDir()
|
|
|
|
}
|