aboutsummaryrefslogtreecommitdiff
path: root/stackless
diff options
context:
space:
mode:
authorGravatar Oleksandr Redko <Oleksandr_Redko@epam.com> 2023-11-24 12:33:04 +0200
committerGravatar GitHub <noreply@github.com> 2023-11-24 11:33:04 +0100
commitf196617f5598f05df49f2c15ffde70a9d908f292 (patch)
tree17029edd8643ee9c4026d188c5ce5edfe93b1141 /stackless
parentEnable wastedassign, whitespace linters; fix issues (#1665) (diff)
downloadfasthttp-f196617f5598f05df49f2c15ffde70a9d908f292.tar.gz
fasthttp-f196617f5598f05df49f2c15ffde70a9d908f292.tar.bz2
fasthttp-f196617f5598f05df49f2c15ffde70a9d908f292.zip
chore: Use 'any' instead of 'interface{}' (#1666)
gofmt -w -r "interface{} -> any" -l .
Diffstat (limited to 'stackless')
-rw-r--r--stackless/func.go8
-rw-r--r--stackless/func_test.go6
-rw-r--r--stackless/func_timing_test.go2
-rw-r--r--stackless/writer.go6
4 files changed, 11 insertions, 11 deletions
diff --git a/stackless/func.go b/stackless/func.go
index 70521e1..c5ef610 100644
--- a/stackless/func.go
+++ b/stackless/func.go
@@ -18,7 +18,7 @@ import (
//
// The stackless wrapper returns false if the call cannot be processed
// at the moment due to high load.
-func NewFunc(f func(ctx interface{})) func(ctx interface{}) bool {
+func NewFunc(f func(ctx any)) func(ctx any) bool {
if f == nil {
// developer sanity-check
panic("BUG: f cannot be nil")
@@ -33,7 +33,7 @@ func NewFunc(f func(ctx interface{})) func(ctx interface{}) bool {
}
var once sync.Once
- return func(ctx interface{}) bool {
+ return func(ctx any) bool {
once.Do(onceInit)
fw := getFuncWork()
fw.ctx = ctx
@@ -50,7 +50,7 @@ func NewFunc(f func(ctx interface{})) func(ctx interface{}) bool {
}
}
-func funcWorker(funcWorkCh <-chan *funcWork, f func(ctx interface{})) {
+func funcWorker(funcWorkCh <-chan *funcWork, f func(ctx any)) {
for fw := range funcWorkCh {
f(fw.ctx)
fw.done <- struct{}{}
@@ -75,6 +75,6 @@ func putFuncWork(fw *funcWork) {
var funcWorkPool sync.Pool
type funcWork struct {
- ctx interface{}
+ ctx any
done chan struct{}
}
diff --git a/stackless/func_test.go b/stackless/func_test.go
index 6b2a8d5..719d10b 100644
--- a/stackless/func_test.go
+++ b/stackless/func_test.go
@@ -11,7 +11,7 @@ func TestNewFuncSimple(t *testing.T) {
t.Parallel()
var n uint64
- f := NewFunc(func(ctx interface{}) {
+ f := NewFunc(func(ctx any) {
atomic.AddUint64(&n, uint64(ctx.(int)))
})
@@ -30,10 +30,10 @@ func TestNewFuncMulti(t *testing.T) {
t.Parallel()
var n1, n2 uint64
- f1 := NewFunc(func(ctx interface{}) {
+ f1 := NewFunc(func(ctx any) {
atomic.AddUint64(&n1, uint64(ctx.(int)))
})
- f2 := NewFunc(func(ctx interface{}) {
+ f2 := NewFunc(func(ctx any) {
atomic.AddUint64(&n2, uint64(ctx.(int)))
})
diff --git a/stackless/func_timing_test.go b/stackless/func_timing_test.go
index e071ae3..8335e4d 100644
--- a/stackless/func_timing_test.go
+++ b/stackless/func_timing_test.go
@@ -7,7 +7,7 @@ import (
func BenchmarkFuncOverhead(b *testing.B) {
var n uint64
- f := NewFunc(func(ctx interface{}) {
+ f := NewFunc(func(ctx any) {
atomic.AddUint64(&n, *(ctx.(*uint64)))
})
b.RunParallel(func(pb *testing.PB) {
diff --git a/stackless/writer.go b/stackless/writer.go
index 347e464..28dbedf 100644
--- a/stackless/writer.go
+++ b/stackless/writer.go
@@ -101,17 +101,17 @@ var errHighLoad = errors.New("cannot compress data due to high load")
var (
stacklessWriterFuncOnce sync.Once
- stacklessWriterFuncFunc func(ctx interface{}) bool
+ stacklessWriterFuncFunc func(ctx any) bool
)
-func stacklessWriterFunc(ctx interface{}) bool {
+func stacklessWriterFunc(ctx any) bool {
stacklessWriterFuncOnce.Do(func() {
stacklessWriterFuncFunc = NewFunc(writerFunc)
})
return stacklessWriterFuncFunc(ctx)
}
-func writerFunc(ctx interface{}) {
+func writerFunc(ctx any) {
w := ctx.(*writer)
switch w.op {
case opWrite: