♻️ 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/*
|
||||
var embedStatic embed.FS
|
||||
|
||||
var static fs.FS = os.DirFS(filepath.Join("web", "static"))
|
||||
var static embed.FS
|
||||
|
||||
func main() {
|
||||
logger := log.New(os.Stdout, "pay\t", log.LstdFlags)
|
||||
|
||||
// static, err := fs.Sub(static, filepath.Join("web", "static"))
|
||||
// if err != nil {
|
||||
// logger.Fatalln(err)
|
||||
// }
|
||||
static, err := fs.Sub(static, filepath.Join("web", "static"))
|
||||
if err != nil {
|
||||
logger.Fatalln(err)
|
||||
}
|
||||
|
||||
cpuProfilePath := flag.String("cpuprofile", "", "set path to saving CPU memory profile")
|
||||
memProfilePath := flag.String("memprofile", "", "set path to saving pprof memory profile")
|
||||
|
@ -42,18 +40,18 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
app := pay.New(logger, static, *config)
|
||||
|
||||
done := make(chan os.Signal, 1)
|
||||
|
||||
signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
if cpuProfilePath != nil && *cpuProfilePath != "" {
|
||||
cpuProfile, err := os.Create(*cpuProfilePath)
|
||||
if err != nil {
|
||||
if *cpuProfilePath != "" {
|
||||
var cpuProfile *os.File
|
||||
if cpuProfile, err = os.Create(*cpuProfilePath); err != nil {
|
||||
logger.Fatalln("could not create CPU profile:", err)
|
||||
}
|
||||
defer cpuProfile.Close()
|
||||
|
@ -68,11 +66,11 @@ func main() {
|
|||
|
||||
<-done
|
||||
|
||||
if err := app.Stop(context.Background()); err != nil {
|
||||
if err = app.Stop(context.Background()); err != nil {
|
||||
logger.Fatalln(err)
|
||||
}
|
||||
|
||||
if memProfilePath == nil && *memProfilePath == "" {
|
||||
if *memProfilePath == "" {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue