This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-satellite.git


The following commit(s) were added to refs/heads/main by this push:
     new 8778e3e  Update go library to `1.23` (#158)
8778e3e is described below

commit 8778e3e8a4ab4962102502ffc9ba7a3c73270609
Author: mrproliu <[email protected]>
AuthorDate: Tue Nov 12 13:17:39 2024 +0900

    Update go library to `1.23` (#158)
---
 .github/workflows/build-and-test.yaml              |  2 +-
 .github/workflows/e2e-istio.yaml                   |  4 +-
 .golangci.yml                                      |  7 ---
 CHANGES.md                                         |  1 +
 Makefile                                           |  2 +-
 docker/Dockerfile                                  |  2 +-
 docs/en/guides/compile/How-to-compile.md           |  2 +-
 go.mod                                             |  2 +-
 plugins/client/grpc/client.go                      | 10 +++-
 plugins/client/grpc/resolvers/kubernetes_kinds.go  |  2 +-
 plugins/client/kafka/client_config.go              | 10 +++-
 plugins/queue/mmap/meta/meta.go                    | 54 +++++++++++++++-------
 plugins/queue/mmap/queue_operation.go              | 19 +++++++-
 plugins/queue/partition/partitioned_queue_test.go  | 10 +++-
 plugins/receiver/grpc/common_test_help.go          |  4 +-
 .../receiver/grpc/nativeprofile/receiver_test.go   | 10 +++-
 plugins/receiver/http/nativcelog/receiver_test.go  |  4 +-
 test/e2e/base/satellite/Dockerfile                 |  2 +-
 18 files changed, 105 insertions(+), 42 deletions(-)

diff --git a/.github/workflows/build-and-test.yaml 
b/.github/workflows/build-and-test.yaml
index 06f7637..f5e660c 100644
--- a/.github/workflows/build-and-test.yaml
+++ b/.github/workflows/build-and-test.yaml
@@ -28,7 +28,7 @@ jobs:
     timeout-minutes: 30
     strategy:
       matrix:
-        go-version: [ 1.21 ]
+        go-version: [ 1.23 ]
         runner: [ ubuntu, windows ]
       fail-fast: true
     steps:
diff --git a/.github/workflows/e2e-istio.yaml b/.github/workflows/e2e-istio.yaml
index ad59e09..83e7467 100644
--- a/.github/workflows/e2e-istio.yaml
+++ b/.github/workflows/e2e-istio.yaml
@@ -43,7 +43,7 @@ jobs:
       - name: Set up Go
         uses: actions/setup-go@v5
         with:
-          go-version: 1.21
+          go-version: 1.23
         id: go
       - uses: actions/checkout@v2
         with:
@@ -75,7 +75,7 @@ jobs:
       - name: Set up Go
         uses: actions/setup-go@v5
         with:
-          go-version: 1.21
+          go-version: 1.23
         id: go
       - uses: actions/checkout@v2
         with:
diff --git a/.golangci.yml b/.golangci.yml
index 526594f..466d7f1 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -17,8 +17,6 @@
 linters-settings:
   govet:
     check-shadowing: true
-  golint:
-    min-confidence: 0
   gocyclo:
     min-complexity: 15
   maligned:
@@ -53,7 +51,6 @@ linters-settings:
 linters:
   enable:
     - bodyclose
-    - deadcode
     - dogsled
     - dupl
     - errcheck
@@ -63,23 +60,19 @@ linters:
     - gocyclo
     - gofmt
     - goimports
-    - golint
     - gosec
     - gosimple
     - govet
     - ineffassign
-    - interfacer
     - lll
     - misspell
     - nakedret
     - staticcheck
-    - structcheck
     - stylecheck
     - typecheck
     - unconvert
     - unparam
     - unused
-    - varcheck
     - whitespace
 
 service:
diff --git a/CHANGES.md b/CHANGES.md
index 6f4bd81..876dda7 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,6 +6,7 @@ Release Notes.
 ------------------
 #### Features
 * Support native eBPF Access Log protocol.
+* Update go library to `1.23`.
 
 #### Bug Fixes
 
diff --git a/Makefile b/Makefile
index c058f05..ce81ab2 100644
--- a/Makefile
+++ b/Makefile
@@ -53,7 +53,7 @@ all: deps verify build gen-docs check
 
 .PHONY: tools
 tools:
-       $(GO_LINT) version || curl -sfL 
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh 
-s -- -b $(GO_PATH)/bin v1.55.0
+       $(GO_LINT) version || curl -sfL 
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh 
-s -- -b $(GO_PATH)/bin v1.62.0
 
 deps: tools
        $(GO_GET) -v -t -d ./...
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 3f60dd9..dbee457 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM golang:1.21 as build
+FROM golang:1.23 as build
 
 ARG VERSION="latest"
 ARG TARGETARCH
diff --git a/docs/en/guides/compile/How-to-compile.md 
b/docs/en/guides/compile/How-to-compile.md
index 98ea473..11df4b8 100644
--- a/docs/en/guides/compile/How-to-compile.md
+++ b/docs/en/guides/compile/How-to-compile.md
@@ -2,7 +2,7 @@
 
 ## Go version
 
-Go version `1.21` is required for compilation.
+Go version `1.23` is required for compilation.
 
 ## Platform
 Linux, MacOS and Windows are supported in SkyWalking Satellite. However, some 
components don't fit the Windows platform, including:
diff --git a/go.mod b/go.mod
index 417e723..7192ab2 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/apache/skywalking-satellite
 
-go 1.21
+go 1.23
 
 require (
        github.com/Shopify/sarama v1.27.2
diff --git a/plugins/client/grpc/client.go b/plugins/client/grpc/client.go
index ff8f257..12f37a3 100644
--- a/plugins/client/grpc/client.go
+++ b/plugins/client/grpc/client.go
@@ -20,6 +20,7 @@ package grpc
 import (
        "context"
        "fmt"
+       "math"
 
        "github.com/sirupsen/logrus"
        "google.golang.org/grpc"
@@ -183,5 +184,12 @@ type logrusGrpcLoggerV2 struct {
 }
 
 func (l *logrusGrpcLoggerV2) V(level int) bool {
-       return l.Logger.IsLevelEnabled(logrus.Level(level))
+       return l.Logger.IsLevelEnabled(logrus.Level(intToUint32(level)))
+}
+
+func intToUint32(value int) uint32 {
+       if value < 0 || value > math.MaxUint32 {
+               return 0
+       }
+       return uint32(value)
 }
diff --git a/plugins/client/grpc/resolvers/kubernetes_kinds.go 
b/plugins/client/grpc/resolvers/kubernetes_kinds.go
index 3e46f69..c8ab905 100644
--- a/plugins/client/grpc/resolvers/kubernetes_kinds.go
+++ b/plugins/client/grpc/resolvers/kubernetes_kinds.go
@@ -112,7 +112,7 @@ func (w *KindCache) watchAndUpdate(ctx context.Context, 
discoverer discovery.Dis
                        select {
                        case tgs := <-ch:
                                for _, tg := range tgs {
-                                       if tg.Targets == nil || len(tg.Targets) 
== 0 {
+                                       if len(tg.Targets) == 0 {
                                                delete(w.cache, tg.Source)
                                                continue
                                        }
diff --git a/plugins/client/kafka/client_config.go 
b/plugins/client/kafka/client_config.go
index 2f350c1..f34f6b6 100644
--- a/plugins/client/kafka/client_config.go
+++ b/plugins/client/kafka/client_config.go
@@ -19,6 +19,7 @@ package kafka
 
 import (
        "fmt"
+       "math"
        "os"
        "time"
 
@@ -37,7 +38,7 @@ func (c *Client) loadConfig() (*sarama.Config, error) {
        cfg.Producer.Return.Errors = true
        cfg.Producer.Idempotent = c.IdempotentWrites
        cfg.Producer.RequiredAcks = sarama.RequiredAcks(c.RequiredAcks)
-       cfg.Producer.Compression = sarama.CompressionCodec(c.CompressionCodec)
+       cfg.Producer.Compression = 
sarama.CompressionCodec(intToInt8(c.CompressionCodec))
        if c.ProducerMaxRetry > 0 {
                cfg.Producer.Retry.Max = c.ProducerMaxRetry
        }
@@ -119,3 +120,10 @@ func checkTLSFile(path string) error {
        }
        return nil
 }
+
+func intToInt8(value int) int8 {
+       if value < math.MinInt8 || value > math.MaxInt8 {
+               return 0
+       }
+       return int8(value)
+}
diff --git a/plugins/queue/mmap/meta/meta.go b/plugins/queue/mmap/meta/meta.go
index 6394ca5..4b74c03 100644
--- a/plugins/queue/mmap/meta/meta.go
+++ b/plugins/queue/mmap/meta/meta.go
@@ -21,6 +21,7 @@ package meta
 
 import (
        "fmt"
+       "math"
        "path/filepath"
        "sync"
        "syscall"
@@ -96,88 +97,88 @@ func NewMetaData(metaDir string, capacity int) (*Metadata, 
error) {
 func (m *Metadata) GetVersion() int {
        m.lock.RLock()
        defer m.lock.RUnlock()
-       return int(m.metaFile.ReadUint64At(versionPos))
+       return uint64ToInt(m.metaFile.ReadUint64At(versionPos))
 }
 
 // PutVersion put the version into the memory mapped file.
 func (m *Metadata) PutVersion(version int64) {
        m.lock.Lock()
        defer m.lock.Unlock()
-       m.metaFile.WriteUint64At(uint64(version), versionPos)
+       m.metaFile.WriteUint64At(int64ToUint64(version), versionPos)
 }
 
 // GetWritingOffset returns the writing offset, which contains the segment ID 
and the offset of the segment.
 func (m *Metadata) GetWritingOffset() (segmentID, offset int64) {
        m.lock.RLock()
        defer m.lock.RUnlock()
-       return int64(m.metaFile.ReadUint64At(widPos)), 
int64(m.metaFile.ReadUint64At(woffsetPos))
+       return uint64ToInt64(m.metaFile.ReadUint64At(widPos)), 
uint64ToInt64(m.metaFile.ReadUint64At(woffsetPos))
 }
 
 // PutWritingOffset put the segment ID and the offset of the segment into the 
writing offset.
 func (m *Metadata) PutWritingOffset(segmentID, offset int64) {
        m.lock.Lock()
        defer m.lock.Unlock()
-       m.metaFile.WriteUint64At(uint64(segmentID), widPos)
-       m.metaFile.WriteUint64At(uint64(offset), woffsetPos)
+       m.metaFile.WriteUint64At(int64ToUint64(segmentID), widPos)
+       m.metaFile.WriteUint64At(int64ToUint64(offset), woffsetPos)
 }
 
 // GetWatermarkOffset returns the watermark offset, which contains the segment 
ID and the offset of the segment.
 func (m *Metadata) GetWatermarkOffset() (segmentID, offset int64) {
        m.lock.RLock()
        defer m.lock.RUnlock()
-       return int64(m.metaFile.ReadUint64At(wmidPos)), 
int64(m.metaFile.ReadUint64At(wmoffsetPos))
+       return uint64ToInt64(m.metaFile.ReadUint64At(wmidPos)), 
uint64ToInt64(m.metaFile.ReadUint64At(wmoffsetPos))
 }
 
 // PutWatermarkOffset put the segment ID and the offset of the segment into 
the watermark offset.
 func (m *Metadata) PutWatermarkOffset(segmentID, offset int64) {
        m.lock.Lock()
        defer m.lock.Unlock()
-       m.metaFile.WriteUint64At(uint64(segmentID), wmidPos)
-       m.metaFile.WriteUint64At(uint64(offset), wmoffsetPos)
+       m.metaFile.WriteUint64At(int64ToUint64(segmentID), wmidPos)
+       m.metaFile.WriteUint64At(int64ToUint64(offset), wmoffsetPos)
 }
 
 // GetCommittedOffset returns the committed offset, which contains the segment 
ID and the offset of the segment.
 func (m *Metadata) GetCommittedOffset() (segmentID, offset int64) {
        m.lock.RLock()
        defer m.lock.RUnlock()
-       return int64(m.metaFile.ReadUint64At(cidPos)), 
int64(m.metaFile.ReadUint64At(coffsetPos))
+       return uint64ToInt64(m.metaFile.ReadUint64At(cidPos)), 
uint64ToInt64(m.metaFile.ReadUint64At(coffsetPos))
 }
 
 // PutCommittedOffset put the segment ID and the offset of the segment into 
the committed offset.
 func (m *Metadata) PutCommittedOffset(segmentID, offset int64) {
        m.lock.Lock()
        defer m.lock.Unlock()
-       m.metaFile.WriteUint64At(uint64(segmentID), cidPos)
-       m.metaFile.WriteUint64At(uint64(offset), coffsetPos)
+       m.metaFile.WriteUint64At(int64ToUint64(segmentID), cidPos)
+       m.metaFile.WriteUint64At(int64ToUint64(offset), coffsetPos)
 }
 
 // GetReadingOffset returns the reading offset, which contains the segment ID 
and the offset of the segment.
 func (m *Metadata) GetReadingOffset() (segmentID, offset int64) {
        m.lock.RLock()
        defer m.lock.RUnlock()
-       return int64(m.metaFile.ReadUint64At(ridPos)), 
int64(m.metaFile.ReadUint64At(roffsetPos))
+       return uint64ToInt64(m.metaFile.ReadUint64At(ridPos)), 
uint64ToInt64(m.metaFile.ReadUint64At(roffsetPos))
 }
 
 // PutReadingOffset put the segment ID and the offset of the segment into the 
reading offset.
 func (m *Metadata) PutReadingOffset(segmentID, offset int64) {
        m.lock.Lock()
        defer m.lock.Unlock()
-       m.metaFile.WriteUint64At(uint64(segmentID), ridPos)
-       m.metaFile.WriteUint64At(uint64(offset), roffsetPos)
+       m.metaFile.WriteUint64At(int64ToUint64(segmentID), ridPos)
+       m.metaFile.WriteUint64At(int64ToUint64(offset), roffsetPos)
 }
 
 // GetCapacity returns the capacity of the queue.
 func (m *Metadata) GetCapacity() int {
        m.lock.RLock()
        defer m.lock.RUnlock()
-       return int(m.metaFile.ReadUint64At(capacityPos))
+       return uint64ToInt(m.metaFile.ReadUint64At(capacityPos))
 }
 
 // PutCapacity put the capacity into the memory mapped file.
 func (m *Metadata) PutCapacity(version int64) {
        m.lock.Lock()
        defer m.lock.Unlock()
-       m.metaFile.WriteUint64At(uint64(version), capacityPos)
+       m.metaFile.WriteUint64At(int64ToUint64(version), capacityPos)
 }
 
 // Flush the memory mapped file to the disk.
@@ -196,3 +197,24 @@ func (m *Metadata) Close() error {
        }
        return m.metaFile.Unmap()
 }
+
+func uint64ToInt(value uint64) int {
+       if value > math.MaxInt {
+               return 0
+       }
+       return int(value)
+}
+
+func int64ToUint64(value int64) uint64 {
+       if value < 0 {
+               return 0
+       }
+       return uint64(value)
+}
+
+func uint64ToInt64(value uint64) int64 {
+       if value > math.MaxInt64 {
+               return 0
+       }
+       return int64(value)
+}
diff --git a/plugins/queue/mmap/queue_operation.go 
b/plugins/queue/mmap/queue_operation.go
index 51702e9..93db224 100644
--- a/plugins/queue/mmap/queue_operation.go
+++ b/plugins/queue/mmap/queue_operation.go
@@ -25,6 +25,7 @@
 package mmap
 
 import (
+       "math"
        "sync/atomic"
 
        "github.com/apache/skywalking-satellite/plugins/queue/api"
@@ -134,7 +135,7 @@ func (q *Queue) readLength(id, offset int64) (newID, 
newOffset int64, length int
        if offset == int64(q.SegmentSize) {
                id, offset = id+1, 0
        }
-       return id, offset, int(num), nil
+       return id, offset, uint64ToInt(num), nil
 }
 
 // writeLength write the data length with 8 Bits spaces.
@@ -147,7 +148,7 @@ func (q *Queue) writeLength(length int, id, offset int64) 
(newID, newOffset int6
        if err != nil {
                return 0, 0, err
        }
-       segment.WriteUint64At(uint64(length), offset)
+       segment.WriteUint64At(intToUint64(length), offset)
        q.unlock(id)
        offset += uInt64Size
        if offset == int64(q.SegmentSize) {
@@ -182,3 +183,17 @@ func (q *Queue) writeBytes(bytes []byte, id, offset int64) 
(newID, newOffset int
        }
        return id, offset, nil
 }
+
+func uint64ToInt(value uint64) int {
+       if value > math.MaxInt {
+               return 0
+       }
+       return int(value)
+}
+
+func intToUint64(value int) uint64 {
+       if value < 0 {
+               return 0
+       }
+       return uint64(value)
+}
diff --git a/plugins/queue/partition/partitioned_queue_test.go 
b/plugins/queue/partition/partitioned_queue_test.go
index 21fe1d7..9ee47c5 100644
--- a/plugins/queue/partition/partitioned_queue_test.go
+++ b/plugins/queue/partition/partitioned_queue_test.go
@@ -19,6 +19,7 @@ package partition
 
 import (
        "fmt"
+       "math"
        "reflect"
        "strconv"
        "testing"
@@ -134,7 +135,7 @@ func TestPartitionQueue(t *testing.T) {
                                }
                        }
 
-                       queue.loadBalancerIndex = int32(tt.loadBalancerIndex)
+                       queue.loadBalancerIndex = 
intToInt32(tt.loadBalancerIndex)
 
                        testDates := initData(tt.testCount)
                        for _, d := range testDates {
@@ -148,3 +149,10 @@ func TestPartitionQueue(t *testing.T) {
                })
        }
 }
+
+func intToInt32(value int) int32 {
+       if value > math.MaxInt32 || value < math.MinInt32 {
+               return 0
+       }
+       return int32(value)
+}
diff --git a/plugins/receiver/grpc/common_test_help.go 
b/plugins/receiver/grpc/common_test_help.go
index 45e64d8..b4fc988 100644
--- a/plugins/receiver/grpc/common_test_help.go
+++ b/plugins/receiver/grpc/common_test_help.go
@@ -87,7 +87,7 @@ func TestReceiverWithConfig(rec receiver.Receiver, recConf 
map[string]string,
                data = dataGenerator(t, i, conn, ctx)
                <-ctx.Done()
                if errorMsg != "" {
-                       t.Fatalf(errorMsg)
+                       t.Fatalf("%s", errorMsg)
                }
        }
 }
@@ -117,7 +117,7 @@ func TestReceiverWithSync(rec receiver.Receiver,
        for i := 0; i < 10; i++ {
                dataGenerator(t, i, conn, &data, context.Background())
                if invoker.errorMsg != "" {
-                       t.Fatalf(invoker.errorMsg)
+                       t.Fatalf("%s", invoker.errorMsg)
                }
        }
 }
diff --git a/plugins/receiver/grpc/nativeprofile/receiver_test.go 
b/plugins/receiver/grpc/nativeprofile/receiver_test.go
index 48b6eb1..8aca45f 100644
--- a/plugins/receiver/grpc/nativeprofile/receiver_test.go
+++ b/plugins/receiver/grpc/nativeprofile/receiver_test.go
@@ -20,6 +20,7 @@ package nativeprofile
 import (
        "context"
        "fmt"
+       "math"
        "testing"
        "time"
 
@@ -41,7 +42,7 @@ func TestReceiver_RegisterHandler_ThreadSnapshot(t 
*testing.T) {
                        TaskId:         fmt.Sprintf("task-%d", sequence),
                        TraceSegmentId: fmt.Sprintf("segment-%d", sequence),
                        Time:           time.Now().Unix(),
-                       Sequence:       int32(sequence),
+                       Sequence:       intToInt32(sequence),
                        Stack: &profile.ThreadStack{
                                CodeSignatures: []string{
                                        "code",
@@ -107,3 +108,10 @@ func TestReceiver_RegisterHandler_ReportTaskFinish(t 
*testing.T) {
                },
        }, t)
 }
+
+func intToInt32(value int) int32 {
+       if value > math.MaxInt32 || value < math.MinInt32 {
+               return 0
+       }
+       return int32(value)
+}
diff --git a/plugins/receiver/http/nativcelog/receiver_test.go 
b/plugins/receiver/http/nativcelog/receiver_test.go
index 40b524c..c516f6f 100644
--- a/plugins/receiver/http/nativcelog/receiver_test.go
+++ b/plugins/receiver/http/nativcelog/receiver_test.go
@@ -50,7 +50,7 @@ func TestReceiver_http_RegisterHandler(t *testing.T) {
        r.RegisterHandler(s.GetServer())
        err := s.Start()
        if err != nil {
-               t.Fatalf(err.Error())
+               t.Fatalf("%s", err.Error())
        }
        time.Sleep(time.Second)
        defer func() {
@@ -99,7 +99,7 @@ func TestReceiver_http_RegisterHandler_failed(t *testing.T) {
        r.RegisterHandler(s.GetServer())
        err := s.Start()
        if err != nil {
-               t.Fatalf(err.Error())
+               t.Fatalf("%s", err.Error())
        }
        time.Sleep(time.Second)
        defer func() {
diff --git a/test/e2e/base/satellite/Dockerfile 
b/test/e2e/base/satellite/Dockerfile
index a6f6737..c990166 100644
--- a/test/e2e/base/satellite/Dockerfile
+++ b/test/e2e/base/satellite/Dockerfile
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM golang:1.21
+FROM golang:1.23
 
 ADD . /satellite_code
 WORKDIR /satellite_code

Reply via email to