Replace packr with go:embed #459
This commit is contained in:
parent
1febd808c3
commit
dff928456d
15
api/text.go
15
api/text.go
@ -1,27 +1,28 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packr"
|
||||
)
|
||||
|
||||
//go:embed embed/*
|
||||
var embedded embed.FS
|
||||
|
||||
// Text contains static overridable texts used in explorer
|
||||
var Text struct {
|
||||
BlockbookAbout, TOSLink string
|
||||
}
|
||||
|
||||
func init() {
|
||||
box := packr.NewBox("../build/text")
|
||||
if about, err := box.MustString("about"); err == nil {
|
||||
Text.BlockbookAbout = strings.TrimSpace(about)
|
||||
if about, err := embedded.ReadFile("embed/about"); err == nil {
|
||||
Text.BlockbookAbout = strings.TrimSpace(string(about))
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
if tosLink, err := box.MustString("tos_link"); err == nil {
|
||||
tosLink = strings.TrimSpace(tosLink)
|
||||
if tosLinkB, err := embedded.ReadFile("embed/tos_link"); err == nil {
|
||||
tosLink := strings.TrimSpace(string(tosLinkB))
|
||||
if _, err := url.ParseRequestURI(tosLink); err == nil {
|
||||
Text.TOSLink = tosLink
|
||||
} else {
|
||||
|
||||
@ -40,9 +40,6 @@ RUN cd /opt/rocksdb && CFLAGS=-fPIC CXXFLAGS=-fPIC make -j 4 release
|
||||
RUN strip /opt/rocksdb/ldb /opt/rocksdb/sst_dump && \
|
||||
cp /opt/rocksdb/ldb /opt/rocksdb/sst_dump /build
|
||||
|
||||
# install build tools
|
||||
RUN go get github.com/gobuffalo/packr/...
|
||||
|
||||
# pre-load depencencies
|
||||
RUN \
|
||||
cleanup() { rm -rf $GOPATH/src/github.com/trezor ; } && \
|
||||
|
||||
@ -9,12 +9,12 @@ ARGS ?=
|
||||
|
||||
all: build tools
|
||||
|
||||
build: prepare-sources generate-data
|
||||
build: prepare-sources
|
||||
cd $(BLOCKBOOK_SRC) && go build -tags rocksdb_6_16 -o $(CURDIR)/blockbook -ldflags="-s -w $(LDFLAGS)" $(ARGS)
|
||||
cp $(CURDIR)/blockbook /out/blockbook
|
||||
chown $(PACKAGER) /out/blockbook
|
||||
|
||||
build-debug: prepare-sources generate-data
|
||||
build-debug: prepare-sources
|
||||
cd $(BLOCKBOOK_SRC) && go build -tags rocksdb_6_16 -o $(CURDIR)/blockbook -ldflags="$(LDFLAGS)" $(ARGS)
|
||||
cp $(CURDIR)/blockbook /out/blockbook
|
||||
chown $(PACKAGER) /out/blockbook
|
||||
@ -23,13 +23,13 @@ tools:
|
||||
cp $(CURDIR)/{ldb,sst_dump} /out
|
||||
chown $(PACKAGER) /out/{ldb,sst_dump}
|
||||
|
||||
test: prepare-sources generate-data
|
||||
test: prepare-sources
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'rocksdb_6_16 unittest' `go list ./... | grep -vP '^github.com/trezor/blockbook/(contrib|tests)'` $(ARGS)
|
||||
|
||||
test-integration: prepare-sources generate-data
|
||||
test-integration: prepare-sources
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'rocksdb_6_16 integration' `go list github.com/trezor/blockbook/tests/...` $(ARGS)
|
||||
|
||||
test-all: prepare-sources generate-data
|
||||
test-all: prepare-sources
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'rocksdb_6_16 unittest integration' `go list ./... | grep -v '^github.com/trezor/blockbook/contrib'` $(ARGS)
|
||||
|
||||
prepare-sources:
|
||||
@ -38,6 +38,3 @@ prepare-sources:
|
||||
mkdir -p $(BLOCKBOOK_BASE)
|
||||
cp -r /src $(BLOCKBOOK_SRC)
|
||||
cd $(BLOCKBOOK_SRC) && go mod download
|
||||
|
||||
generate-data:
|
||||
cd $(BLOCKBOOK_SRC) && packr clean && packr
|
||||
|
||||
2
go.mod
2
go.mod
@ -20,7 +20,6 @@ require (
|
||||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
|
||||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
|
||||
github.com/flier/gorocksdb v0.0.0-20210322035443-567cc51a1652
|
||||
github.com/gobuffalo/packr v1.13.7
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||
github.com/golang/protobuf v1.4.3
|
||||
@ -59,7 +58,6 @@ require (
|
||||
github.com/go-ole/go-ole v1.2.1 // indirect
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.14.0 // indirect
|
||||
github.com/prometheus/procfs v0.2.0 // indirect
|
||||
|
||||
4
go.sum
4
go.sum
@ -229,8 +229,6 @@ github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gobuffalo/packr v1.13.7 h1:2uZgLd6b/W4yRBZV/ScaORxZLNGMHO0VCvqQNkKukNA=
|
||||
github.com/gobuffalo/packr v1.13.7/go.mod h1:KkinLIn/n6+3tVXMwg6KkNvWwVsrRAz4ph+jgpk3Z24=
|
||||
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
@ -571,7 +569,6 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg=
|
||||
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
|
||||
@ -672,7 +669,6 @@ golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73r
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180921000356-2f5d2388922f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
|
||||
Loading…
Reference in New Issue
Block a user