Skip to content

Commit 15b217a

Browse files
authored
Bump CI versions, fix a few linting errors (#103)
1 parent 369f257 commit 15b217a

File tree

8 files changed

+34
-21
lines changed

8 files changed

+34
-21
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
tests:
1212
strategy:
1313
matrix:
14-
go-version: [1.17.x, 1.18.x, 1.19.x]
14+
go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x]
1515
os: [ubuntu-latest]
1616
runs-on: ${{ matrix.os }}
1717
steps:

.golangci.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ issues:
33
- G203
44

55
run:
6-
timeout: 10m
6+
timeout: 5m
77

88
linters:
99
enable-all: true
@@ -33,12 +33,9 @@ linters:
3333
- nestif
3434
- funlen
3535
- goconst
36-
- nlreturn
37-
- gochecknoglobals
3836
- cyclop
3937
- gocyclo
4038
- gocognit
4139
- maintidx
42-
- contextcheck
4340
- wrapcheck
44-
- gomnd
41+
- depguard

fs_embed.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ func (tfs tmplFS) Walk(root string, walkFn filepath.WalkFunc) error {
4141
if err != nil {
4242
return err
4343
}
44+
4445
info, err := d.Info()
46+
4547
return walkFn(path, info, err)
4648
})
4749
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ go 1.17
44

55
require github.com/fsnotify/fsnotify v1.6.0
66

7-
require golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
7+
require golang.org/x/sys v0.13.0 // indirect

go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
22
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
3-
golang.org/x/sys v0.0.0-20220908164124-27713097b956 h1:XeJjHH1KiLpKGb6lvMiksZ9l0fVUh+AmGcm0nOMEBOY=
43
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4+
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
5+
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

helpers.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ import (
66
)
77

88
// Included helper functions for use when rendering HTML.
9-
var helperFuncs = template.FuncMap{
10-
"yield": func() (string, error) {
11-
return "", fmt.Errorf("yield called with no layout defined")
12-
},
13-
"partial": func() (string, error) {
14-
return "", fmt.Errorf("block called with no layout defined")
15-
},
16-
"current": func() (string, error) {
17-
return "", nil
18-
},
9+
func helperFuncs() template.FuncMap {
10+
return template.FuncMap{
11+
"yield": func() (string, error) {
12+
return "", fmt.Errorf("yield called with no layout defined")
13+
},
14+
"partial": func() (string, error) {
15+
return "", fmt.Errorf("block called with no layout defined")
16+
},
17+
"current": func() (string, error) {
18+
return "", nil
19+
},
20+
}
1921
}

render.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ const (
3636
ContentXML = "text/xml"
3737
// Default character encoding.
3838
defaultCharset = "UTF-8"
39+
// Buffer pool size.
40+
bufferPoolSize = 32
41+
// Buffer pool capacity.
42+
bufferPoolCapacity = 1 << 19
3943
)
4044

4145
// helperFuncs had to be moved out. See helpers.go|helpers_pre16.go files.
@@ -197,7 +201,7 @@ func (r *Render) prepareOptions() {
197201
}
198202

199203
if r.opt.BufferPool == nil {
200-
r.opt.BufferPool = NewSizedBufferPool(32, 1<<19) // 32 buffers of size 512KiB each
204+
r.opt.BufferPool = NewSizedBufferPool(bufferPoolSize, bufferPoolCapacity)
201205
}
202206

203207
if r.opt.IsDevelopment || r.opt.UseMutexLock {
@@ -210,6 +214,7 @@ func (r *Render) prepareOptions() {
210214
func (r *Render) CompileTemplates() {
211215
if r.opt.Asset == nil || r.opt.AssetNames == nil {
212216
r.compileTemplatesFromDir()
217+
213218
return
214219
}
215220

@@ -276,10 +281,12 @@ func (r *Render) compileTemplatesFromDir() {
276281
}
277282

278283
// Break out if this parsing fails. We don't want any silent server starts.
279-
template.Must(tmpl.Funcs(helperFuncs).Parse(string(buf)))
284+
template.Must(tmpl.Funcs(helperFuncs()).Parse(string(buf)))
285+
280286
break
281287
}
282288
}
289+
283290
return nil
284291
})
285292

@@ -346,7 +353,7 @@ func (r *Render) compileTemplatesFromAsset() {
346353
}
347354

348355
// Break out if this parsing fails. We don't want any silent server starts.
349-
template.Must(tmpl.Funcs(helperFuncs).Parse(string(buf)))
356+
template.Must(tmpl.Funcs(helperFuncs()).Parse(string(buf)))
350357

351358
break
352359
}
@@ -370,6 +377,7 @@ func (r *Render) TemplateLookup(t string) *template.Template {
370377

371378
func (r *Render) execute(templates *template.Template, name string, binding interface{}) (*bytes.Buffer, error) {
372379
buf := new(bytes.Buffer)
380+
373381
return buf, templates.ExecuteTemplate(buf, name, binding)
374382
}
375383

@@ -395,6 +403,7 @@ func (r *Render) layoutFuncs(templates *template.Template, name string, binding
395403
// Return safe HTML here since we are rendering our own template.
396404
return template.HTML(buf.String()), err
397405
}
406+
398407
return "", nil
399408
},
400409
"partial": func(partialName string) (template.HTML, error) {
@@ -407,6 +416,7 @@ func (r *Render) layoutFuncs(templates *template.Template, name string, binding
407416
// Return safe HTML here since we are rendering our own template.
408417
return template.HTML(buf.String()), err
409418
}
419+
410420
return "", nil
411421
},
412422
}

render_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010
)
1111

12+
//nolint:gochecknoglobals
1213
var ctx = context.Background()
1314

1415
func TestLockConfig(t *testing.T) {

0 commit comments

Comments
 (0)