replace packr with golang native embed package
MODIFY
Makefile
Makefile
@@ -32,14 +32,13 @@ endif
all: $(GO_TARGETS)
clean:
- cd $(GO_SRC) && packr clean
rm -rf go/pkg go/bin $(GO_TARGETS)
tidy:
cd $(GO_SRC) && go mod tidy
realclean: clean
- rm -f .packr .lint
+ rm -f .lint
cd $(GO_SRC) && go clean -modcache
install: $(GO_INSTALL_TARGETS)
@@ -50,14 +49,7 @@ uninstall:
GO_MODULES = $(patsubst %,$(GO_SRC)/%, client.go server.go datatypes.go server_state.go failover_state.go redis.go redis_shim.go redis_server_info.go logging.go version.go garbage_collect_keys.go notification_mailer.go config.go delete_keys.go copy_keys.go dump_expiries.go consul/consul.go)
-.packr:
- go get github.com/gobuffalo/packr/packr
- touch .packr
-
-$(GO_SRC)/a_main-packr.go: $(wildcard $(GO_SRC)/templates/*.html) .packr
- cd $(GO_SRC) && packr
-
-beetle: $(GO_SRC)/beetle.go $(GO_MODULES) $(GO_SRC)/a_main-packr.go
+beetle: $(GO_SRC)/beetle.go $(GO_MODULES)
cd $(GO_SRC) && $(GO_ENV) go build -o ../$@
test: test-main test-server

MODIFY
go/server.go
go/server.go
@@ -7,11 +7,20 @@ import (
"syscall"
"time"
+ _ "embed"
+
// "github.com/davecgh/go-spew/spew"
"github.com/gobuffalo/packr"
"github.com/xing/beetle/consul"
)
+var (
+ //go:embed templates/index.html
+ htmlTemplate string
+ //go:embed templates/gcstats.html
+ gcStatsTemplate string
+)
+
// waits on a sync.WaitGroup, but times out after given duration.
func waitForWaitGroupWithTimeout(wg *sync.WaitGroup, timeout time.Duration) bool {
c := make(chan struct{})
@@ -27,11 +36,6 @@ func waitForWaitGroupWithTimeout(wg *sync.WaitGroup, timeout time.Duration) bool
}
}
-var (
- htmlTemplate string
- gcStatsTemplate string
-)
-
func waitForInterrupt() {
done := make(chan os.Signal, 1)
signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)

replace packr with golang native embed package