go 调用
最后更新于:2022-04-02 04:02:42
[TOC]
```
import (
"fmt"
"log"
"github.com/vladimirvivien/gowfs"
)
var fs *gowfs.FileSystem
func main() {
fs, err := gowfs.NewFileSystem(gowfs.Configuration{Addr: "192.168.0.110:50070", User: "im_user"})
if err != nil{
log.Fatal(err)
}
//获取文件信息
checksum, err := fs.GetFileChecksum(gowfs.Path{Name: `/input/README.txt`})
if err != nil {
log.Fatal(err)
}
fmt.Println(string(checksum.Bytes))
fmt.Println (checksum)
//创建目录
createTestDir( "/user/kafka/hello2")
}
func createTestDir(hdfsPath string) {
path := gowfs.Path{Name:hdfsPath}
ok, err := fs.MkDirs(path, 0744)
if err != nil || !ok {
log.Fatal("Unable to create test directory ", hdfsPath, ":", err)
}
log.Println ("HDFS Path ", path.Name, " created.")
}
```
';