NEW: add a example that packs files into the go binary

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-09-03 11:37:50 -05:00
parent 844c0cd201
commit b9f59ddd81
4 changed files with 48 additions and 0 deletions

View File

@ -33,6 +33,7 @@ build:
cd example-lookupAAAA; go install # nslookup cd example-lookupAAAA; go install # nslookup
cd example-json-decode; go install # raw golang byte handling cd example-json-decode; go install # raw golang byte handling
cd example-ssh; go install # scp example cd example-ssh; go install # scp example
cd example-packr; go install # pack a directory into a go binary
# golang things # golang things
cd example-flag; go install # process argv cd example-flag; go install # process argv
@ -44,12 +45,22 @@ build:
# witgoget='-v -t' make prep # witgoget='-v -t' make prep
# witgoget='-v -t -u' make prep # to update # witgoget='-v -t -u' make prep # to update
prep: prep:
witgoget='-v -t' make base
update:
witgoget='-v -t -u' make base
base:
make -C example-nohup prep make -C example-nohup prep
make -C example-expect prep make -C example-expect prep
make -C example-shell prep make -C example-shell prep
make -C example-gocui-mouse prep make -C example-gocui-mouse prep
make -C example-systray prep make -C example-systray prep
make -C example-lookupAAAA prep make -C example-lookupAAAA prep
make -C example-gui prep
init:
sudo make -C example-systray init
sub-make: sub-make:
# shell things # shell things

2
example-packr/Makefile Normal file
View File

@ -0,0 +1,2 @@
build:
go build

19
example-packr/main.go Normal file
View File

@ -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)
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<TrustAnchor id="380DC50D-484E-40D0-A3AE-68F2B18F61C7" source="http://data.iana.org/root-anchors/root-anchors.xml">
<Zone>.</Zone>
<KeyDigest id="Kjqmt7v" validFrom="2010-07-15T00:00:00+00:00" validUntil="2019-01-11T00:00:00+00:00">
<KeyTag>19036</KeyTag>
<Algorithm>8</Algorithm>
<DigestType>2</DigestType>
<Digest>49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5</Digest>
</KeyDigest>
<KeyDigest id="Klajeyz" validFrom="2017-02-02T00:00:00+00:00">
<KeyTag>20326</KeyTag>
<Algorithm>8</Algorithm>
<DigestType>2</DigestType>
<Digest>E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D</Digest>
</KeyDigest>
</TrustAnchor>