Skip to content

Commit

Permalink
Merge pull request #70 from gofiber/fix-gomod
Browse files Browse the repository at this point in the history
Fix mismatch minimum go version to match gofiber/fiber
  • Loading branch information
ReneWerner87 authored Feb 26, 2024
2 parents 4af06b1 + 4bd4f93 commit 17c184a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.21.x
go-version: 1.20.x

- name: Fetch Repository
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
Build:
strategy:
matrix:
go-version: [1.20.x, 1.21.x]
go-version: [1.20.x, 1.21.x, 1.22.x]
platform: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
6 changes: 4 additions & 2 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@ import (
"unsafe"
)

// #nosec G103
// UnsafeString returns a string pointer without allocation
func UnsafeString(b []byte) string {
// the new way is slower `return unsafe.String(unsafe.SliceData(b), len(b))`
// unsafe.Pointer variant: 0.3538 ns/op vs unsafe.String variant: 0.5410 ns/op
// #nosec G103
return *(*string)(unsafe.Pointer(&b))
}

// #nosec G103
// UnsafeBytes returns a byte pointer without allocation.
func UnsafeBytes(s string) []byte {
// #nosec G103
return unsafe.Slice(unsafe.StringData(s), len(s))
}

// CopyString copies a string to make it immutable
func CopyString(s string) string {
// #nosec G103
return string(UnsafeBytes(s))
}

// #nosec G103
// CopyBytes copies a slice to make it immutable
func CopyBytes(b []byte) []byte {
tmp := make([]byte, len(b))
Expand Down
3 changes: 1 addition & 2 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error {
return walk(fs, root, info, walkFn)
}

// #nosec G304
// ReadFile returns the raw content of a file
func ReadFile(path string, fs http.FileSystem) ([]byte, error) {
if fs != nil {
Expand All @@ -32,7 +31,7 @@ func ReadFile(path string, fs http.FileSystem) ([]byte, error) {
defer file.Close()
return io.ReadAll(file)
}
return os.ReadFile(path)
return os.ReadFile(path) // #nosec G304
}

// readDirNames reads the directory named by dirname and returns
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/gofiber/utils/v2

go 1.21
go 1.20

require (
github.com/google/uuid v1.6.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

1 comment on commit 17c184a

@ReneWerner87
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 17c184a Previous: 4af06b1 Ratio
Benchmark_IsIPv4/default - B/op 16 B/op 0 B/op +∞
Benchmark_IsIPv4/default - allocs/op 1 allocs/op 0 allocs/op +∞
Benchmark_IsIPv6/default - B/op 16 B/op 0 B/op +∞
Benchmark_IsIPv6/default - allocs/op 1 allocs/op 0 allocs/op +∞

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.