From 8818037535751dec7ca553c20f4efe3d7bad2059 Mon Sep 17 00:00:00 2001 From: colinsi <67437960+colin-si@users.noreply.github.com> Date: Wed, 13 Dec 2023 14:35:17 +0800 Subject: [PATCH 1/3] Update util.go Solve the problem of function parameters being recycled by GC --- pkg/util/util.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/util/util.go b/pkg/util/util.go index 525518697..ede501b76 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -57,9 +57,12 @@ func BytesToStringWithNoCopy(bytes []byte) string { } func StringToBytesWithNoCopy(s string) []byte { - x := (*[2]uintptr)(unsafe.Pointer(&s)) - h := [3]uintptr{x[0], x[1], x[1]} - return *(*[]byte)(unsafe.Pointer(&h)) + return *(*[]byte)(unsafe.Pointer( + &struct { + string + Cap int + }{str, len(str)}, + )) } func ListToMap(list []string) map[string]struct{} { From 428dd65969fd80cd724af56846e80968309a67d0 Mon Sep 17 00:00:00 2001 From: colinsi <67437960+colin-si@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:53:31 +0800 Subject: [PATCH 2/3] Update util.go Solve the problem of function parameters being recycled by GC --- pkg/util/util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/util/util.go b/pkg/util/util.go index ede501b76..4c7e15aa9 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -61,7 +61,7 @@ func StringToBytesWithNoCopy(s string) []byte { &struct { string Cap int - }{str, len(str)}, + }{s, len(s)}, )) } From e0f9ff4ff8798fbedf969624845d15ba9bd03a39 Mon Sep 17 00:00:00 2001 From: colinsi <67437960+colin-si@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:58:47 +0800 Subject: [PATCH 3/3] Update golangci-lint.yml --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index bf0dce231..0bb619aa2 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -9,5 +9,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.51.2 + version: v1.55.2 args: --timeout=5m --skip-dirs='api,test,.*/controller/(v3|v4)$,.*/bootstrap$,examples,integration' --enable gofmt,revive,gocyclo,goimports --skip-files=.*_test.go$