From b9f59ddd81ed607866d66366405a41dcfa5f88b1 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 3 Sep 2021 11:37:50 -0500 Subject: [PATCH] NEW: add a example that packs files into the go binary Signed-off-by: Jeff Carr --- Makefile | 11 +++++++++++ example-packr/Makefile | 2 ++ example-packr/main.go | 19 +++++++++++++++++++ example-packr/resources/root-anchors.xml | 16 ++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 example-packr/Makefile create mode 100644 example-packr/main.go create mode 100644 example-packr/resources/root-anchors.xml diff --git a/Makefile b/Makefile index 37a34b1..53bc7c1 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,7 @@ build: cd example-lookupAAAA; go install # nslookup cd example-json-decode; go install # raw golang byte handling cd example-ssh; go install # scp example + cd example-packr; go install # pack a directory into a go binary # golang things cd example-flag; go install # process argv @@ -44,12 +45,22 @@ build: # witgoget='-v -t' make prep # witgoget='-v -t -u' make prep # to update prep: + witgoget='-v -t' make base + +update: + witgoget='-v -t -u' make base + +base: make -C example-nohup prep make -C example-expect prep make -C example-shell prep make -C example-gocui-mouse prep make -C example-systray prep make -C example-lookupAAAA prep + make -C example-gui prep + +init: + sudo make -C example-systray init sub-make: # shell things diff --git a/example-packr/Makefile b/example-packr/Makefile new file mode 100644 index 0000000..79eee22 --- /dev/null +++ b/example-packr/Makefile @@ -0,0 +1,2 @@ +build: + go build diff --git a/example-packr/main.go b/example-packr/main.go new file mode 100644 index 0000000..b9d33ba --- /dev/null +++ b/example-packr/main.go @@ -0,0 +1,19 @@ +package main + +import "log" +import "github.com/gobuffalo/packr" + +var packrBox packr.Box + +func main() { + + log.Println("packr ./resources box") + + // This puts all the files in that directory in the binary + // This directory includes the default config file if there is not already one + packrBox = packr.NewBox("./resources") + + filename := "root-anchors.xml" + b, _ := packrBox.FindString(filename) + log.Println(filename, "=\n\n", b) +} diff --git a/example-packr/resources/root-anchors.xml b/example-packr/resources/root-anchors.xml new file mode 100644 index 0000000..3536f08 --- /dev/null +++ b/example-packr/resources/root-anchors.xml @@ -0,0 +1,16 @@ + + +. + +19036 +8 +2 +49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5 + + +20326 +8 +2 +E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D + +