Skip to content

Commit

Permalink
use Go v1.17 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
SVilgelm authored Oct 1, 2021
1 parent 8e1058d commit 79813cc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 36 deletions.
25 changes: 4 additions & 21 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ on:
- cron: "0 0 * * 0"

env:
GO: 1.16
GO: 1.17

jobs:
CodeQL:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest

permissions:
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
Expand Down Expand Up @@ -69,21 +70,3 @@ jobs:
version: latest
skip-build-cache: true
skip-go-installation: true

Nancy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO }}

- name: Prepare go list
run: go list -json -m all > go.list

- name: Run Nancy
uses: sonatype-nexus-community/[email protected]
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- "v[0-9]+.[0-9]+.[0-9]+"

env:
GO: 1.16
GO: 1.17

jobs:
bump-version:
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ linters:
- gocyclo
- goerr113
- gofumpt
- golint
- goprintffuncname
- gosec
- ifshort
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ifeq ($(shell uname), Darwin)
all: brew-install
endif

all: tidy lint nancy test done
all: tidy lint test done

done:
@echo "$(OK_COLOR)==> Done.$(NO_COLOR)"
Expand All @@ -26,10 +26,6 @@ run-benchmark:

test: run-test run-benchmark

nancy:
@echo "$(OK_COLOR)==> Checking Vulnerability via nancy...$(NO_COLOR)"
@go list -json -m all | nancy sleuth --quiet

lint:
@echo "$(OK_COLOR)==> Linting via golangci-lint...$(NO_COLOR)"
@golangci-lint run --fix ./...
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
The small library with an implementation of Buffer Pool.
The library was created to avoid repeating this code.

Here is a good article how to use implement and properly use the Buffer Pools: https://www.captaincodeman.com/2017/06/02/golang-buffer-pool-gotcha
Here is a good article how to implement and properly use the Buffer Pools: https://www.captaincodeman.com/2017/06/02/golang-buffer-pool-gotcha

## Usage

Expand All @@ -16,30 +16,30 @@ package main

import (
"fmt"
"sync"
"sync"
"text/template"

buffferspool "github.com/sv-tools/buffers-pool"
)

func render(template string, data interface{}) (string, error) {
tmpl, err := template.New("test").Parse(template)
func render(tmpl string, data interface{}) (string, error) {
tp, err := template.New("test").Parse(tmpl)
if err != nil {
return "", err
}

buf := buffferspool.Get()
defer buffferspool.Put(buf)

if err := tmpl.Execute(buf, data); err != nil {
if err := tp.Execute(buf, data); err != nil {
return "", err
}

return buf.String(), nil
}

func main() {
var template string
var tmpl string
var data []interface{}
// ... load template and data to variables ...

Expand All @@ -49,7 +49,7 @@ func main() {
wg.Add(1)
go func(data interface{}) {
defer wg.Done()
val, err := render(data)
val, err := render(tmpl, data)
if err != nil {
res <- err.Error()
return
Expand All @@ -69,7 +69,6 @@ func main() {
}
```


## License

MIT licensed. See the bundled [LICENSE](LICENSE) file for more details.

0 comments on commit 79813cc

Please sign in to comment.