Skip to content

Instantly share code, notes, and snippets.

@wangkuiyi
Created December 2, 2015 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangkuiyi/c227f258156ddb32e047 to your computer and use it in GitHub Desktop.
Save wangkuiyi/c227f258156ddb32e047 to your computer and use it in GitHub Desktop.
// This simple program shows how to use the write-support branch of
// https://github.com/colinmarc/hdfs/, which accesses HDFS of Hadoop
// 2.2.x throught the native protobuf-based RPC protocol
package main
import (
"flag"
"fmt"
"log"
"github.com/colinmarc/hdfs"
)
func main() {
namenode := flag.String("namenode", "localhost:9000", "Address of HDFS namenode")
flag.Parse()
dfs, e := hdfs.New(*namenode)
if e != nil {
log.Fatal(e)
}
w, e := dfs.Create("/hello.txt")
if e != nil {
log.Fatal(e)
}
r, e := w.Write([]byte("Hello, World!\n"))
if e != nil {
log.Fatal(e)
}
fmt.Println("written ", r)
w.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment