summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/GeertJohan/go.rice/example/example.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-08-06 21:47:05 +0200
committerWim <wim@42.be>2018-08-06 21:47:05 +0200
commit51062863a5c34d81e296cf15c61140911037cf3b (patch)
tree9b5e044672486326c7a0ca8fb26430f37bf4d83c /vendor/github.com/GeertJohan/go.rice/example/example.go
parent4fb4b7aa6c02a54db8ad8dd98e4d321396926c0d (diff)
downloadmatterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.gz
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.bz2
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.zip
Use mod vendor for vendored directory (backwards compatible)
Diffstat (limited to 'vendor/github.com/GeertJohan/go.rice/example/example.go')
-rw-r--r--vendor/github.com/GeertJohan/go.rice/example/example.go69
1 files changed, 0 insertions, 69 deletions
diff --git a/vendor/github.com/GeertJohan/go.rice/example/example.go b/vendor/github.com/GeertJohan/go.rice/example/example.go
deleted file mode 100644
index 68f189f3..00000000
--- a/vendor/github.com/GeertJohan/go.rice/example/example.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package main
-
-import (
- "encoding/hex"
- "fmt"
- "log"
- "net/http"
- "os"
- "text/template"
-
- "github.com/GeertJohan/go.rice"
- "github.com/davecgh/go-spew/spew"
-)
-
-func main() {
- conf := rice.Config{
- LocateOrder: []rice.LocateMethod{rice.LocateEmbedded, rice.LocateAppended, rice.LocateFS},
- }
- box, err := conf.FindBox("example-files")
- if err != nil {
- log.Fatalf("error opening rice.Box: %s\n", err)
- }
- // spew.Dump(box)
-
- contentString, err := box.String("file.txt")
- if err != nil {
- log.Fatalf("could not read file contents as string: %s\n", err)
- }
- log.Printf("Read some file contents as string:\n%s\n", contentString)
-
- contentBytes, err := box.Bytes("file.txt")
- if err != nil {
- log.Fatalf("could not read file contents as byteSlice: %s\n", err)
- }
- log.Printf("Read some file contents as byteSlice:\n%s\n", hex.Dump(contentBytes))
-
- file, err := box.Open("file.txt")
- if err != nil {
- log.Fatalf("could not open file: %s\n", err)
- }
- spew.Dump(file)
-
- // find/create a rice.Box
- templateBox, err := rice.FindBox("example-templates")
- if err != nil {
- log.Fatal(err)
- }
- // get file contents as string
- templateString, err := templateBox.String("message.tmpl")
- if err != nil {
- log.Fatal(err)
- }
- // parse and execute the template
- tmplMessage, err := template.New("message").Parse(templateString)
- if err != nil {
- log.Fatal(err)
- }
- tmplMessage.Execute(os.Stdout, map[string]string{"Message": "Hello, world!"})
-
- http.Handle("/", http.FileServer(box.HTTPBox()))
- go func() {
- fmt.Println("Serving files on :8080, press ctrl-C to exit")
- err := http.ListenAndServe(":8080", nil)
- if err != nil {
- log.Fatalf("error serving files: %v", err)
- }
- }()
- select {}
-}