Skip to content

Commit 6028c04

Browse files
committed
Add some missing file closes
1 parent 67ae166 commit 6028c04

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ require (
126126
golang.org/x/oauth2 v0.15.0 // indirect
127127
golang.org/x/sys v0.15.0 // indirect
128128
google.golang.org/appengine v1.6.8 // indirect
129-
google.golang.org/protobuf v1.31.0 // indirect
129+
google.golang.org/protobuf v1.32.0 // indirect
130130
gopkg.in/ini.v1 v1.67.0 // indirect
131131
maunium.net/go/maulogger/v2 v2.4.1 // indirect
132132
willnorris.com/go/webmention v0.0.0-20220108183051-4a23794272f0 // indirect

Diff for: go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAs
378378
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
379379
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
380380
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
381-
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
382-
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
381+
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
382+
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
383383
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
384384
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
385385
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

Diff for: httpFs.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ func (a *goBlog) serveFs(f fs.FS, basePath string) http.HandlerFunc {
2929
default:
3030
_, _ = io.Copy(w, file)
3131
}
32+
_ = file.Close()
3233
}
3334
}

Diff for: main.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ func main() {
6767
return
6868
}
6969

70-
// Initialize plugins
71-
if err = app.initPlugins(); err != nil {
72-
app.logErrAndQuit("Failed to init plugins:", err.Error())
73-
return
74-
}
75-
7670
// Healthcheck tool
7771
if len(os.Args) >= 2 && os.Args[1] == "healthcheck" {
7872
// Connect to public address + "/ping" and exit with 0 when successful
@@ -97,6 +91,12 @@ func main() {
9791
return
9892
}
9993

94+
// Initialize plugins
95+
if err = app.initPlugins(); err != nil {
96+
app.logErrAndQuit("Failed to init plugins:", err.Error())
97+
return
98+
}
99+
100100
// Start pprof server
101101
if pprofCfg := app.cfg.Pprof; pprofCfg != nil && pprofCfg.Enabled {
102102
go func() {

Diff for: pkgs/highlighting/highlighting.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ type highlighting struct{}
9595
// Highlighting is a goldmark.Extender implementation.
9696
var Highlighting = &highlighting{}
9797

98-
var Style = styles.Monokai
98+
var Style = styles.Get("monokai")
9999

100100
// Extend implements goldmark.Extender.
101101
func (*highlighting) Extend(m goldmark.Markdown) {

Diff for: plugins/customcss/src/customcss/customcss.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ func (p *plugin) RenderWithDocument(_ plugintypes.RenderContext, doc *goquery.Do
4747
fmt.Println("Failed to open custom css file: ", err.Error())
4848
return
4949
}
50-
defer func() {
51-
_ = f.Close()
52-
}()
5350

5451
err = p.app.CompileAsset("plugincustomcss.css", f)
52+
_ = f.Close()
5553
if err != nil {
5654
fmt.Println("Failed compile custom css: ", err.Error())
5755
return

Diff for: profileImage.go

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func (a *goBlog) profileImageHash() string {
157157
return nil, nil
158158
}
159159
_, _ = io.Copy(hash, file)
160+
_ = file.Close()
160161
a.profileImageHashString = fmt.Sprintf("%x", hash.Sum(nil))
161162
return nil, nil
162163
})
@@ -194,6 +195,7 @@ func (a *goBlog) serveUpdateProfileImage(w http.ResponseWriter, r *http.Request)
194195
}
195196
_, err = io.Copy(dataFile, file)
196197
_ = file.Close()
198+
_ = dataFile.Close()
197199
if err != nil {
198200
a.serveError(w, r, "Failed to save image", http.StatusBadRequest)
199201
return

0 commit comments

Comments
 (0)