Skip to content

Commit

Permalink
all: migrate go-bindata to embed (ethereum#24744)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Jan 22, 2025
1 parent 2779b08 commit ffbe4f5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 590 deletions.
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 a 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 @@ -91,6 +89,9 @@ var (
ether = new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)
)

//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 @@ -122,13 +123,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
Loading

0 comments on commit ffbe4f5

Please sign in to comment.