From 8e892d31ed6aa224c9dfc1e6af1f369eda119666 Mon Sep 17 00:00:00 2001 From: James Mills Date: Wed, 14 Sep 2016 14:17:31 +1000 Subject: [PATCH] Add examples for inline godoc display --- gopher_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 gopher_test.go diff --git a/gopher_test.go b/gopher_test.go new file mode 100644 index 0000000..9a75c12 --- /dev/null +++ b/gopher_test.go @@ -0,0 +1,25 @@ +package gopher_test + +import ( + "fmt" + "log" + + "github.com/prologic/go-gopher" +) + +func hello(w gopher.ResponseWriter, r *gopher.Request) { + w.WriteInfo("Hello World!") +} + +func ExampleClient() { + res, err := gopher.Get("gopher://gopher.floodgap.com") + if err != nil { + log.Fatal(err) + } + fmt.Print(res.Dir.ToText()) +} + +func ExampleServer() { + gopher.HandleFunc("/hello", hello) + log.Fatal(gopher.ListenAndServe("localhost:7000", nil)) +}