Skip to content

Commit

Permalink
Add some missing file closes
Browse files Browse the repository at this point in the history
  • Loading branch information
jlelse committed Dec 25, 2023
1 parent 67ae166 commit 6028c04
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
1 change: 1 addition & 0 deletions httpFs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ func (a *goBlog) serveFs(f fs.FS, basePath string) http.HandlerFunc {
default:
_, _ = io.Copy(w, file)
}
_ = file.Close()
}
}
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/highlighting/highlighting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions plugins/customcss/src/customcss/customcss.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions profileImage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6028c04

Please sign in to comment.