♻️ Use embed static, removed nilness warning
/ docker (push) Successful in 59s
Details
/ docker (push) Successful in 59s
Details
This commit is contained in:
parent
9e4afd6738
commit
0eb2f09131
26
main.go
26
main.go
|
@ -24,17 +24,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed web/static/*
|
//go:embed web/static/*
|
||||||
var embedStatic embed.FS
|
var static embed.FS
|
||||||
|
|
||||||
var static fs.FS = os.DirFS(filepath.Join("web", "static"))
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logger := log.New(os.Stdout, "pay\t", log.LstdFlags)
|
logger := log.New(os.Stdout, "pay\t", log.LstdFlags)
|
||||||
|
|
||||||
// static, err := fs.Sub(static, filepath.Join("web", "static"))
|
static, err := fs.Sub(static, filepath.Join("web", "static"))
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// logger.Fatalln(err)
|
logger.Fatalln(err)
|
||||||
// }
|
}
|
||||||
|
|
||||||
cpuProfilePath := flag.String("cpuprofile", "", "set path to saving CPU memory profile")
|
cpuProfilePath := flag.String("cpuprofile", "", "set path to saving CPU memory profile")
|
||||||
memProfilePath := flag.String("memprofile", "", "set path to saving pprof memory profile")
|
memProfilePath := flag.String("memprofile", "", "set path to saving pprof memory profile")
|
||||||
|
@ -42,18 +40,18 @@ func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
config := new(domain.Config)
|
config := new(domain.Config)
|
||||||
if err := env.ParseWithOptions(config, env.Options{Prefix: "PAY_"}); err != nil {
|
if err = env.ParseWithOptions(config, env.Options{Prefix: "PAY_"}); err != nil {
|
||||||
logger.Fatalln(err)
|
logger.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
app := pay.New(logger, static, *config)
|
app := pay.New(logger, static, *config)
|
||||||
|
|
||||||
done := make(chan os.Signal, 1)
|
done := make(chan os.Signal, 1)
|
||||||
|
|
||||||
signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
||||||
if cpuProfilePath != nil && *cpuProfilePath != "" {
|
if *cpuProfilePath != "" {
|
||||||
cpuProfile, err := os.Create(*cpuProfilePath)
|
var cpuProfile *os.File
|
||||||
if err != nil {
|
if cpuProfile, err = os.Create(*cpuProfilePath); err != nil {
|
||||||
logger.Fatalln("could not create CPU profile:", err)
|
logger.Fatalln("could not create CPU profile:", err)
|
||||||
}
|
}
|
||||||
defer cpuProfile.Close()
|
defer cpuProfile.Close()
|
||||||
|
@ -68,11 +66,11 @@ func main() {
|
||||||
|
|
||||||
<-done
|
<-done
|
||||||
|
|
||||||
if err := app.Stop(context.Background()); err != nil {
|
if err = app.Stop(context.Background()); err != nil {
|
||||||
logger.Fatalln(err)
|
logger.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if memProfilePath == nil && *memProfilePath == "" {
|
if *memProfilePath == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue