Skip to content

Commit 7ab1549

Browse files
authored
all: use 'embed' instead of go-bindata (#24744)
1 parent 63972e7 commit 7ab1549

File tree

15 files changed

+49
-148163
lines changed

15 files changed

+49
-148163
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ clean:
4343

4444
devtools:
4545
env GOBIN= go install golang.org/x/tools/cmd/stringer@latest
46-
env GOBIN= go install github.com/kevinburke/go-bindata/go-bindata@latest
4746
env GOBIN= go install github.com/fjl/gencodec@latest
4847
env GOBIN= go install github.com/golang/protobuf/protoc-gen-go@latest
4948
env GOBIN= go install ./cmd/abigen

build/tools/tools.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
// Tool imports for go:generate.
2424
_ "github.com/fjl/gencodec"
2525
_ "github.com/golang/protobuf/protoc-gen-go"
26-
_ "github.com/kevinburke/go-bindata/go-bindata"
2726
_ "golang.org/x/tools/cmd/stringer"
2827

2928
// Tool imports for mobile build.

cmd/faucet/faucet.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717
// faucet is an Ether faucet backed by a light client.
1818
package main
1919

20-
//go:generate go run github.com/kevinburke/go-bindata/go-bindata -nometadata -o website.go faucet.html
21-
//go:generate gofmt -w -s website.go
22-
2320
import (
2421
"bytes"
2522
"context"
23+
_ "embed"
2624
"encoding/json"
2725
"errors"
2826
"flag"
@@ -99,6 +97,9 @@ var (
9997
gitDate = "" // Git commit date YYYYMMDD of the release (set via linker flags)
10098
)
10199

100+
//go:embed faucet.html
101+
var websiteTmpl string
102+
102103
func main() {
103104
// Parse the flags and set up the logger to print everything requested
104105
flag.Parse()
@@ -130,13 +131,8 @@ func main() {
130131
periods[i] = strings.TrimSuffix(periods[i], "s")
131132
}
132133
}
133-
// Load up and render the faucet website
134-
tmpl, err := Asset("faucet.html")
135-
if err != nil {
136-
log.Crit("Failed to load the faucet template", "err", err)
137-
}
138134
website := new(bytes.Buffer)
139-
err = template.Must(template.New("").Parse(string(tmpl))).Execute(website, map[string]interface{}{
135+
err := template.Must(template.New("").Parse(websiteTmpl)).Execute(website, map[string]interface{}{
140136
"Network": *netnameFlag,
141137
"Amounts": amounts,
142138
"Periods": periods,

cmd/faucet/website.go

Lines changed: 0 additions & 274 deletions
This file was deleted.

console/console.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,10 @@ func (c *Console) initConsoleObject() {
179179
}
180180

181181
func (c *Console) initWeb3(bridge *bridge) error {
182-
bnJS := string(deps.MustAsset("bignumber.js"))
183-
web3JS := string(deps.MustAsset("web3.js"))
184-
if err := c.jsre.Compile("bignumber.js", bnJS); err != nil {
182+
if err := c.jsre.Compile("bignumber.js", deps.BigNumberJS); err != nil {
185183
return fmt.Errorf("bignumber.js: %v", err)
186184
}
187-
if err := c.jsre.Compile("web3.js", web3JS); err != nil {
185+
if err := c.jsre.Compile("web3.js", deps.Web3JS); err != nil {
188186
return fmt.Errorf("web3.js: %v", err)
189187
}
190188
if _, err := c.jsre.Run("var Web3 = require('web3');"); err != nil {

eth/tracers/js/internal/tracers/assets.go

Lines changed: 0 additions & 458 deletions
This file was deleted.

eth/tracers/js/internal/tracers/tracers.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17-
//go:generate go run github.com/kevinburke/go-bindata/go-bindata -nometadata -o assets.go -pkg tracers -ignore tracers.go -ignore assets.go ./...
18-
//go:generate gofmt -s -w assets.go
19-
2017
// Package tracers contains the actual JavaScript tracer assets.
2118
package tracers
19+
20+
import "embed"
21+
22+
//go:embed *.js
23+
var FS embed.FS

eth/tracers/js/tracer.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17-
// package js is a collection of tracers written in javascript.
17+
// Package js is a collection of tracers written in javascript.
1818
package js
1919

2020
import (
2121
"encoding/json"
2222
"errors"
2323
"fmt"
24+
"io/fs"
2425
"math/big"
2526
"strings"
2627
"sync/atomic"
@@ -51,9 +52,23 @@ var assetTracers = make(map[string]string)
5152

5253
// init retrieves the JavaScript transaction tracers included in go-ethereum.
5354
func init() {
54-
for _, file := range tracers.AssetNames() {
55-
name := camel(strings.TrimSuffix(file, ".js"))
56-
assetTracers[name] = string(tracers.MustAsset(file))
55+
err := fs.WalkDir(tracers.FS, ".", func(path string, d fs.DirEntry, err error) error {
56+
if err != nil {
57+
return err
58+
}
59+
if d.IsDir() {
60+
return nil
61+
}
62+
b, err := fs.ReadFile(tracers.FS, path)
63+
if err != nil {
64+
return err
65+
}
66+
name := camel(strings.TrimSuffix(path, ".js"))
67+
assetTracers[name] = string(b)
68+
return nil
69+
})
70+
if err != nil {
71+
panic(err)
5772
}
5873
tracers2.RegisterLookup(true, newJsTracer)
5974
}
@@ -685,7 +700,7 @@ func (jst *jsTracer) CaptureTxStart(gasLimit uint64) {
685700
jst.gasLimit = gasLimit
686701
}
687702

688-
// CaptureTxStart implements the Tracer interface and is invoked at the end of
703+
// CaptureTxEnd implements the Tracer interface and is invoked at the end of
689704
// transaction processing.
690705
func (*jsTracer) CaptureTxEnd(restGas uint64) {}
691706

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/ethereum/go-ethereum
22

3-
go 1.15
3+
go 1.16
44

55
require (
66
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0
@@ -46,7 +46,6 @@ require (
4646
github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e
4747
github.com/julienschmidt/httprouter v1.2.0
4848
github.com/karalabe/usb v0.0.2
49-
github.com/kevinburke/go-bindata v3.23.0+incompatible
5049
github.com/kylelemons/godebug v1.1.0 // indirect
5150
github.com/mattn/go-colorable v0.1.8
5251
github.com/mattn/go-isatty v0.0.12

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E
256256
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
257257
github.com/karalabe/usb v0.0.2 h1:M6QQBNxF+CQ8OFvxrT90BA0qBOXymndZnk5q235mFc4=
258258
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
259-
github.com/kevinburke/go-bindata v3.23.0+incompatible h1:rqNOXZlqrYhMVVAsQx8wuc+LaA73YcfbQ407wAykyS8=
260-
github.com/kevinburke/go-bindata v3.23.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=
261259
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
262260
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
263261
github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=

internal/jsre/deps/bindata.go

Lines changed: 0 additions & 297 deletions
This file was deleted.

internal/jsre/deps/deps.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,12 @@
1717
// Package deps contains the console JavaScript dependencies Go embedded.
1818
package deps
1919

20-
//go:generate go run github.com/kevinburke/go-bindata/go-bindata -nometadata -pkg deps -o bindata.go bignumber.js web3.js
21-
//go:generate gofmt -w -s bindata.go
20+
import (
21+
_ "embed"
22+
)
23+
24+
//go:embed web3.js
25+
var Web3JS string
26+
27+
//go:embed bignumber.js
28+
var BigNumberJS string

0 commit comments

Comments
 (0)