diff --git a/Makefile b/Makefile index c0441440..4d9968ef 100644 --- a/Makefile +++ b/Makefile @@ -8,30 +8,24 @@ PKGNAME = span .PHONY: all assets bench clean clean-docs cloc deb deps imports lint members names rpm test vet # http://docs.travis-ci.com/user/languages/go/#Default-Test-Script -test: assets deps +test: deps go get github.com/kylelemons/godebug/pretty go get github.com/kr/pretty go test ./... -all: assets deps $(TARGETS) - -assets: assetutil/bindata.go - -assetutil/bindata.go: - go generate +all: deps $(TARGETS) deps: go get -v ./... $(TARGETS): %: cmd/%/main.go - go build -ldflags=-linkmode=external -o $@ $< + go build -ldflags="-w -s -linkmode=external" -o $@ $< clean: rm -f $(TARGETS) rm -f $(PKGNAME)_*deb rm -f $(PKGNAME)-*rpm rm -rf ./packaging/deb/$(PKGNAME)/usr - rm -f assetutil/bindata.go # Code quality and performance. lint: diff --git a/assets.go b/assets.go index 81d09368..6411b7fe 100644 --- a/assets.go +++ b/assets.go @@ -1,3 +1,6 @@ -//go:generate go get -u github.com/jteeuwen/go-bindata/... -//go:generate go-bindata -o assetutil/bindata.go -pkg assetutil assets/... package span + +import "embed" + +//go:embed assets +var Static embed.FS diff --git a/assetutil/helper.go b/assetutil/helper.go index b94c525b..339c1b02 100644 --- a/assetutil/helper.go +++ b/assetutil/helper.go @@ -29,6 +29,7 @@ import ( "regexp" "strings" + "github.com/miku/span" "github.com/miku/span/container" ) @@ -57,8 +58,8 @@ func (r RegexpMap) LookupDefault(s, def string) string { // MustLoadRegexpMap loads the content of a given asset path into a RegexpMap. It // will panic, if the asset path is not found and if the patterns found in the // file cannot be compiled. -func MustLoadRegexpMap(ap string) RegexpMap { - b, err := Asset(ap) +func MustLoadRegexpMap(path string) RegexpMap { + b, err := span.Static.ReadFile(path) if err != nil { panic(err) } @@ -77,7 +78,7 @@ func MustLoadRegexpMap(ap string) RegexpMap { func MustLoadStringSet(paths ...string) *container.StringSet { s := container.NewStringSet() for _, path := range paths { - b, err := Asset(path) + b, err := span.Static.ReadFile(path) if err != nil { panic(err) } @@ -104,7 +105,7 @@ func MustLoadStringSet(paths ...string) *container.StringSet { // container.StringMap. This function will panic, if the asset cannot be found // or the JSON is erroneous. func MustLoadStringMap(path string) container.StringMap { - b, err := Asset(path) + b, err := span.Static.ReadFile(path) if err != nil { panic(err) } @@ -120,7 +121,7 @@ func MustLoadStringMap(path string) container.StringMap { // a container.StringSliceMap. This function will halt the world, if it is // called with an invalid argument. func MustLoadStringSliceMap(path string) container.StringSliceMap { - b, err := Asset(path) + b, err := span.Static.ReadFile(path) if err != nil { panic(err) }