Skip to content

Commit

Permalink
all: use 'embed' instead of go-bindata (#24744)
Browse files Browse the repository at this point in the history
  • Loading branch information
s7v7nislands authored Apr 25, 2022
1 parent 63972e7 commit 7ab1549
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 148,163 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ clean:

devtools:
env GOBIN= go install golang.org/x/tools/cmd/stringer@latest
env GOBIN= go install github.com/kevinburke/go-bindata/go-bindata@latest
env GOBIN= go install github.com/fjl/gencodec@latest
env GOBIN= go install github.com/golang/protobuf/protoc-gen-go@latest
env GOBIN= go install ./cmd/abigen
Expand Down
1 change: 0 additions & 1 deletion build/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
// Tool imports for go:generate.
_ "github.com/fjl/gencodec"
_ "github.com/golang/protobuf/protoc-gen-go"
_ "github.com/kevinburke/go-bindata/go-bindata"
_ "golang.org/x/tools/cmd/stringer"

// Tool imports for mobile build.
Expand Down
14 changes: 5 additions & 9 deletions cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
// faucet is an Ether faucet backed by a light client.
package main

//go:generate go run github.com/kevinburke/go-bindata/go-bindata -nometadata -o website.go faucet.html
//go:generate gofmt -w -s website.go

import (
"bytes"
"context"
_ "embed"
"encoding/json"
"errors"
"flag"
Expand Down Expand Up @@ -99,6 +97,9 @@ var (
gitDate = "" // Git commit date YYYYMMDD of the release (set via linker flags)
)

//go:embed faucet.html
var websiteTmpl string

func main() {
// Parse the flags and set up the logger to print everything requested
flag.Parse()
Expand Down Expand Up @@ -130,13 +131,8 @@ func main() {
periods[i] = strings.TrimSuffix(periods[i], "s")
}
}
// Load up and render the faucet website
tmpl, err := Asset("faucet.html")
if err != nil {
log.Crit("Failed to load the faucet template", "err", err)
}
website := new(bytes.Buffer)
err = template.Must(template.New("").Parse(string(tmpl))).Execute(website, map[string]interface{}{
err := template.Must(template.New("").Parse(websiteTmpl)).Execute(website, map[string]interface{}{
"Network": *netnameFlag,
"Amounts": amounts,
"Periods": periods,
Expand Down
274 changes: 0 additions & 274 deletions cmd/faucet/website.go

This file was deleted.

6 changes: 2 additions & 4 deletions console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,10 @@ func (c *Console) initConsoleObject() {
}

func (c *Console) initWeb3(bridge *bridge) error {
bnJS := string(deps.MustAsset("bignumber.js"))
web3JS := string(deps.MustAsset("web3.js"))
if err := c.jsre.Compile("bignumber.js", bnJS); err != nil {
if err := c.jsre.Compile("bignumber.js", deps.BigNumberJS); err != nil {
return fmt.Errorf("bignumber.js: %v", err)
}
if err := c.jsre.Compile("web3.js", web3JS); err != nil {
if err := c.jsre.Compile("web3.js", deps.Web3JS); err != nil {
return fmt.Errorf("web3.js: %v", err)
}
if _, err := c.jsre.Run("var Web3 = require('web3');"); err != nil {
Expand Down
458 changes: 0 additions & 458 deletions eth/tracers/js/internal/tracers/assets.go

This file was deleted.

8 changes: 5 additions & 3 deletions eth/tracers/js/internal/tracers/tracers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

//go:generate go run github.com/kevinburke/go-bindata/go-bindata -nometadata -o assets.go -pkg tracers -ignore tracers.go -ignore assets.go ./...
//go:generate gofmt -s -w assets.go

// Package tracers contains the actual JavaScript tracer assets.
package tracers

import "embed"

//go:embed *.js
var FS embed.FS
25 changes: 20 additions & 5 deletions eth/tracers/js/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// package js is a collection of tracers written in javascript.
// Package js is a collection of tracers written in javascript.
package js

import (
"encoding/json"
"errors"
"fmt"
"io/fs"
"math/big"
"strings"
"sync/atomic"
Expand Down Expand Up @@ -51,9 +52,23 @@ var assetTracers = make(map[string]string)

// init retrieves the JavaScript transaction tracers included in go-ethereum.
func init() {
for _, file := range tracers.AssetNames() {
name := camel(strings.TrimSuffix(file, ".js"))
assetTracers[name] = string(tracers.MustAsset(file))
err := fs.WalkDir(tracers.FS, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
b, err := fs.ReadFile(tracers.FS, path)
if err != nil {
return err
}
name := camel(strings.TrimSuffix(path, ".js"))
assetTracers[name] = string(b)
return nil
})
if err != nil {
panic(err)
}
tracers2.RegisterLookup(true, newJsTracer)
}
Expand Down Expand Up @@ -685,7 +700,7 @@ func (jst *jsTracer) CaptureTxStart(gasLimit uint64) {
jst.gasLimit = gasLimit
}

// CaptureTxStart implements the Tracer interface and is invoked at the end of
// CaptureTxEnd implements the Tracer interface and is invoked at the end of
// transaction processing.
func (*jsTracer) CaptureTxEnd(restGas uint64) {}

Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ethereum/go-ethereum

go 1.15
go 1.16

require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0
Expand Down Expand Up @@ -46,7 +46,6 @@ require (
github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e
github.com/julienschmidt/httprouter v1.2.0
github.com/karalabe/usb v0.0.2
github.com/kevinburke/go-bindata v3.23.0+incompatible
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.8
github.com/mattn/go-isatty v0.0.12
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
github.com/karalabe/usb v0.0.2 h1:M6QQBNxF+CQ8OFvxrT90BA0qBOXymndZnk5q235mFc4=
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/kevinburke/go-bindata v3.23.0+incompatible h1:rqNOXZlqrYhMVVAsQx8wuc+LaA73YcfbQ407wAykyS8=
github.com/kevinburke/go-bindata v3.23.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
Expand Down
297 changes: 0 additions & 297 deletions internal/jsre/deps/bindata.go

This file was deleted.

11 changes: 9 additions & 2 deletions internal/jsre/deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@
// Package deps contains the console JavaScript dependencies Go embedded.
package deps

//go:generate go run github.com/kevinburke/go-bindata/go-bindata -nometadata -pkg deps -o bindata.go bignumber.js web3.js
//go:generate gofmt -w -s bindata.go
import (
_ "embed"
)

//go:embed web3.js
var Web3JS string

//go:embed bignumber.js
var BigNumberJS string
Loading

0 comments on commit 7ab1549

Please sign in to comment.