diff --git a/go.mod b/go.mod index 5730c95..7a3ee52 100644 --- a/go.mod +++ b/go.mod @@ -126,7 +126,7 @@ require ( golang.org/x/oauth2 v0.15.0 // indirect golang.org/x/sys v0.15.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.32.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect maunium.net/go/maulogger/v2 v2.4.1 // indirect willnorris.com/go/webmention v0.0.0-20220108183051-4a23794272f0 // indirect diff --git a/go.sum b/go.sum index 0aef4fa..65c42d6 100644 --- a/go.sum +++ b/go.sum @@ -378,8 +378,8 @@ google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAs google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/httpFs.go b/httpFs.go index 1bb2cf9..4ace892 100644 --- a/httpFs.go +++ b/httpFs.go @@ -29,5 +29,6 @@ func (a *goBlog) serveFs(f fs.FS, basePath string) http.HandlerFunc { default: _, _ = io.Copy(w, file) } + _ = file.Close() } } diff --git a/main.go b/main.go index 3c907fc..2089c42 100644 --- a/main.go +++ b/main.go @@ -67,12 +67,6 @@ func main() { return } - // Initialize plugins - if err = app.initPlugins(); err != nil { - app.logErrAndQuit("Failed to init plugins:", err.Error()) - return - } - // Healthcheck tool if len(os.Args) >= 2 && os.Args[1] == "healthcheck" { // Connect to public address + "/ping" and exit with 0 when successful @@ -97,6 +91,12 @@ func main() { return } + // Initialize plugins + if err = app.initPlugins(); err != nil { + app.logErrAndQuit("Failed to init plugins:", err.Error()) + return + } + // Start pprof server if pprofCfg := app.cfg.Pprof; pprofCfg != nil && pprofCfg.Enabled { go func() { diff --git a/pkgs/highlighting/highlighting.go b/pkgs/highlighting/highlighting.go index 47ffd49..2f9f616 100644 --- a/pkgs/highlighting/highlighting.go +++ b/pkgs/highlighting/highlighting.go @@ -95,7 +95,7 @@ type highlighting struct{} // Highlighting is a goldmark.Extender implementation. var Highlighting = &highlighting{} -var Style = styles.Monokai +var Style = styles.Get("monokai") // Extend implements goldmark.Extender. func (*highlighting) Extend(m goldmark.Markdown) { diff --git a/plugins/customcss/src/customcss/customcss.go b/plugins/customcss/src/customcss/customcss.go index 0620760..b3d6d01 100644 --- a/plugins/customcss/src/customcss/customcss.go +++ b/plugins/customcss/src/customcss/customcss.go @@ -47,11 +47,9 @@ func (p *plugin) RenderWithDocument(_ plugintypes.RenderContext, doc *goquery.Do fmt.Println("Failed to open custom css file: ", err.Error()) return } - defer func() { - _ = f.Close() - }() err = p.app.CompileAsset("plugincustomcss.css", f) + _ = f.Close() if err != nil { fmt.Println("Failed compile custom css: ", err.Error()) return diff --git a/profileImage.go b/profileImage.go index 9ec8f14..7afacc3 100644 --- a/profileImage.go +++ b/profileImage.go @@ -157,6 +157,7 @@ func (a *goBlog) profileImageHash() string { return nil, nil } _, _ = io.Copy(hash, file) + _ = file.Close() a.profileImageHashString = fmt.Sprintf("%x", hash.Sum(nil)) return nil, nil }) @@ -194,6 +195,7 @@ func (a *goBlog) serveUpdateProfileImage(w http.ResponseWriter, r *http.Request) } _, err = io.Copy(dataFile, file) _ = file.Close() + _ = dataFile.Close() if err != nil { a.serveError(w, r, "Failed to save image", http.StatusBadRequest) return