Skip to content

Commit

Permalink
Bump CI versions, fix a few linting errors (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
unrolled authored Oct 17, 2023
1 parent 369f257 commit 15b217a
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
tests:
strategy:
matrix:
go-version: [1.17.x, 1.18.x, 1.19.x]
go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
7 changes: 2 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ issues:
- G203

run:
timeout: 10m
timeout: 5m

linters:
enable-all: true
Expand Down Expand Up @@ -33,12 +33,9 @@ linters:
- nestif
- funlen
- goconst
- nlreturn
- gochecknoglobals
- cyclop
- gocyclo
- gocognit
- maintidx
- contextcheck
- wrapcheck
- gomnd
- depguard
2 changes: 2 additions & 0 deletions fs_embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ func (tfs tmplFS) Walk(root string, walkFn filepath.WalkFunc) error {
if err != nil {
return err
}

info, err := d.Info()

return walkFn(path, info, err)
})
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ go 1.17

require github.com/fsnotify/fsnotify v1.6.0

require golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
require golang.org/x/sys v0.13.0 // indirect
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
golang.org/x/sys v0.0.0-20220908164124-27713097b956 h1:XeJjHH1KiLpKGb6lvMiksZ9l0fVUh+AmGcm0nOMEBOY=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
22 changes: 12 additions & 10 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import (
)

// Included helper functions for use when rendering HTML.
var helperFuncs = template.FuncMap{
"yield": func() (string, error) {
return "", fmt.Errorf("yield called with no layout defined")
},
"partial": func() (string, error) {
return "", fmt.Errorf("block called with no layout defined")
},
"current": func() (string, error) {
return "", nil
},
func helperFuncs() template.FuncMap {
return template.FuncMap{
"yield": func() (string, error) {
return "", fmt.Errorf("yield called with no layout defined")
},
"partial": func() (string, error) {
return "", fmt.Errorf("block called with no layout defined")
},
"current": func() (string, error) {
return "", nil
},
}
}
16 changes: 13 additions & 3 deletions render.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const (
ContentXML = "text/xml"
// Default character encoding.
defaultCharset = "UTF-8"
// Buffer pool size.
bufferPoolSize = 32
// Buffer pool capacity.
bufferPoolCapacity = 1 << 19
)

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

if r.opt.BufferPool == nil {
r.opt.BufferPool = NewSizedBufferPool(32, 1<<19) // 32 buffers of size 512KiB each
r.opt.BufferPool = NewSizedBufferPool(bufferPoolSize, bufferPoolCapacity)
}

if r.opt.IsDevelopment || r.opt.UseMutexLock {
Expand All @@ -210,6 +214,7 @@ func (r *Render) prepareOptions() {
func (r *Render) CompileTemplates() {
if r.opt.Asset == nil || r.opt.AssetNames == nil {
r.compileTemplatesFromDir()

return
}

Expand Down Expand Up @@ -276,10 +281,12 @@ func (r *Render) compileTemplatesFromDir() {
}

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

break
}
}

return nil
})

Expand Down Expand Up @@ -346,7 +353,7 @@ func (r *Render) compileTemplatesFromAsset() {
}

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

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

func (r *Render) execute(templates *template.Template, name string, binding interface{}) (*bytes.Buffer, error) {
buf := new(bytes.Buffer)

return buf, templates.ExecuteTemplate(buf, name, binding)
}

Expand All @@ -395,6 +403,7 @@ func (r *Render) layoutFuncs(templates *template.Template, name string, binding
// Return safe HTML here since we are rendering our own template.
return template.HTML(buf.String()), err
}

return "", nil
},
"partial": func(partialName string) (template.HTML, error) {
Expand All @@ -407,6 +416,7 @@ func (r *Render) layoutFuncs(templates *template.Template, name string, binding
// Return safe HTML here since we are rendering our own template.
return template.HTML(buf.String()), err
}

return "", nil
},
}
Expand Down
1 change: 1 addition & 0 deletions render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"
)

//nolint:gochecknoglobals
var ctx = context.Background()

func TestLockConfig(t *testing.T) {
Expand Down

0 comments on commit 15b217a

Please sign in to comment.