mirror of
https://github.com/tenox7/wrp.git
synced 2024-11-21 19:30:48 +00:00
Merge pull request #97 from DrJosh9000/master
Replace statik with embed
This commit is contained in:
commit
9e77aa7261
10
Makefile
10
Makefile
@ -1,21 +1,19 @@
|
||||
all: wrp
|
||||
|
||||
wrp: wrp.go statik
|
||||
wrp: wrp.go
|
||||
go build wrp.go
|
||||
|
||||
cross: statik
|
||||
cross:
|
||||
GOOS=linux GOARCH=amd64 go build -a -o wrp-amd64-linux wrp.go
|
||||
GOOS=freebsd GOARCH=amd64 go build -a -o wrp-amd64-freebsd wrp.go
|
||||
GOOS=openbsd GOARCH=amd64 go build -a -o wrp-amd64-openbsd wrp.go
|
||||
GOOS=darwin GOARCH=amd64 go build -a -o wrp-amd64-macos wrp.go
|
||||
GOOS=darwin GOARCH=arm64 go build -a -o wrp-arm64-macos wrp.go
|
||||
GOOS=windows GOARCH=amd64 go build -a -o wrp-amd64-windows.exe wrp.go
|
||||
GOOS=windows GOARCH=386 go build -a -o wrp-386-windows.exe wrp.go
|
||||
GOOS=linux GOARCH=arm go build -a -o wrp-arm-linux wrp.go
|
||||
GOOS=linux GOARCH=arm64 go build -a -o wrp-arm64-linux wrp.go
|
||||
|
||||
statik: wrp.html
|
||||
go generate
|
||||
|
||||
docker: wrp
|
||||
docker build -t tenox7/wrp:latest .
|
||||
|
||||
@ -27,4 +25,4 @@ gcrio:
|
||||
docker push gcr.io/tenox7/wrp
|
||||
|
||||
clean:
|
||||
rm -rf wrp-* wrp statik
|
||||
rm -rf wrp-* wrp
|
||||
|
1
go.mod
1
go.mod
@ -7,6 +7,5 @@ require (
|
||||
github.com/chromedp/cdproto v0.0.0-20210305224431-50b9f457e822
|
||||
github.com/chromedp/chromedp v0.6.8
|
||||
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4
|
||||
github.com/rakyll/statik v0.1.7
|
||||
golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b // indirect
|
||||
)
|
||||
|
14
wrp.go
14
wrp.go
@ -5,13 +5,12 @@
|
||||
// Copyright (c) 2019-2021 Google LLC
|
||||
//
|
||||
|
||||
//go:generate statik -f -src=. -include=wrp.html
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"html/template"
|
||||
@ -37,8 +36,6 @@ import (
|
||||
"github.com/chromedp/cdproto/page"
|
||||
"github.com/chromedp/chromedp"
|
||||
"github.com/ericpauley/go-quantize/quantize"
|
||||
"github.com/rakyll/statik/fs"
|
||||
_ "github.com/tenox7/wrp/statik"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -54,6 +51,9 @@ var (
|
||||
htmlTmpl *template.Template
|
||||
)
|
||||
|
||||
// go:embed *.html
|
||||
var fs embed.FS
|
||||
|
||||
type geom struct {
|
||||
w int64
|
||||
h int64
|
||||
@ -416,11 +416,7 @@ func tmpl(t string) string {
|
||||
return string(tmpl)
|
||||
|
||||
statik:
|
||||
sfs, err := fs.New()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fhs, err := sfs.Open("/wrp.html")
|
||||
fhs, err := fs.Open("/wrp.html")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user