Created
December 2, 2015 17:16
-
-
Save wangkuiyi/c227f258156ddb32e047 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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