all: use 'embed' instead of go-bindata (#24744)

This commit is contained in:
s7v7nislands
2022-04-25 11:15:14 +02:00
committed by GitHub
parent 63972e7548
commit 7ab15490e9
15 changed files with 49 additions and 148163 deletions
+5 -9
View File
@@ -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"
@@ -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()
@@ -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,
File diff suppressed because one or more lines are too long