[VOL-5374] Upgrade go version to v1.23
Change-Id: I0d051ebfee3e4117e4f6d83f512c7ee791fd1d19
Signed-off-by: Akash Reddy Kankanala <akash.kankanala@radisys.com>
diff --git a/pkg/adapters/common/utils.go b/pkg/adapters/common/utils.go
index 17a6aae..7a5c815 100644
--- a/pkg/adapters/common/utils.go
+++ b/pkg/adapters/common/utils.go
@@ -23,26 +23,26 @@
// GetRandomSerialNumber returns a serial number formatted as "HOST:PORT"
func GetRandomSerialNumber() string {
- rand.Seed(time.Now().UnixNano())
+ r := rand.New(rand.NewSource(time.Now().UnixNano()))
return fmt.Sprintf("%d.%d.%d.%d:%d",
- rand.Intn(255),
- rand.Intn(255),
- rand.Intn(255),
- rand.Intn(255),
- rand.Intn(9000)+1000,
+ r.Intn(255),
+ r.Intn(255),
+ r.Intn(255),
+ r.Intn(255),
+ r.Intn(9000)+1000,
)
}
// GetRandomMacAddress returns a random mac address
func GetRandomMacAddress() string {
- rand.Seed(time.Now().UnixNano())
+ r := rand.New(rand.NewSource(time.Now().UnixNano()))
return fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
- rand.Intn(128),
- rand.Intn(128),
- rand.Intn(128),
- rand.Intn(128),
- rand.Intn(128),
- rand.Intn(128),
+ r.Intn(128),
+ r.Intn(128),
+ r.Intn(128),
+ r.Intn(128),
+ r.Intn(128),
+ r.Intn(128),
)
}
diff --git a/pkg/flows/flow_utils.go b/pkg/flows/flow_utils.go
index 04c248c..8a6333f 100755
--- a/pkg/flows/flow_utils.go
+++ b/pkg/flows/flow_utils.go
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+//nolint:staticcheck
package flows
import (
@@ -347,7 +348,14 @@
if flow == nil {
return nil
}
- nFlow := (proto.Clone(flow)).(*ofp.OfpFlowStats)
+ flowData, err := proto.Marshal(flow)
+ if err != nil {
+ return nil // Handle error appropriately
+ }
+ nFlow := &ofp.OfpFlowStats{}
+ if err := proto.Unmarshal(flowData, nFlow); err != nil {
+ return nil // Handle error appropriately
+ }
nFlow.Instructions = nil
nInsts := make([]*ofp.OfpInstruction, 0)
for _, instruction := range flow.Instructions {
diff --git a/pkg/flows/flow_utils_test.go b/pkg/flows/flow_utils_test.go
index 3518580..9704600 100644
--- a/pkg/flows/flow_utils_test.go
+++ b/pkg/flows/flow_utils_test.go
@@ -109,7 +109,7 @@
KV: OfpFlowModArgs{"priority": 500},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
},
Actions: []*ofp.OfpAction{
SetField(VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 10)),
@@ -175,7 +175,7 @@
KV: OfpFlowModArgs{"priority": 1500},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(5),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
},
Actions: []*ofp.OfpAction{
PushVlan(0x8100),
@@ -229,7 +229,7 @@
KV: OfpFlowModArgs{"priority": 500},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -276,7 +276,7 @@
KV: OfpFlowModArgs{"priority": 500},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
Metadata_ofp(1000),
TunnelId(uint64(1)),
VlanPcp(0),
@@ -388,7 +388,7 @@
KV: OfpFlowModArgs{"priority": 500},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
Metadata_ofp(1000),
TunnelId(uint64(1)),
VlanPcp(0),
@@ -422,7 +422,7 @@
KV: OfpFlowModArgs{"priority": 2000},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
Metadata_ofp(1000),
TunnelId(uint64(1)),
VlanPcp(0),
@@ -469,7 +469,7 @@
KV: OfpFlowModArgs{"priority": 2000},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
Metadata_ofp(1000),
TunnelId(uint64(1)),
VlanPcp(0),
@@ -488,7 +488,7 @@
KV: OfpFlowModArgs{"priority": 2000},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
},
}
flow, err = MkFlowStat(fa)
@@ -504,7 +504,7 @@
KV: OfpFlowModArgs{"priority": 500},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -522,7 +522,7 @@
KV: OfpFlowModArgs{"priority": 500},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -542,7 +542,7 @@
KV: OfpFlowModArgs{"priority": 500, "table_id": 1, "cookie": 38268468, "flags": 12},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -560,7 +560,7 @@
KV: OfpFlowModArgs{"priority": 500},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -579,7 +579,7 @@
KV: OfpFlowModArgs{"priority": 500, "table_id": 1, "cookie": 38268468, "flags": 12},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -594,7 +594,7 @@
KV: OfpFlowModArgs{"priority": 501, "table_id": 1, "cookie": 38268468, "flags": 12},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -612,7 +612,7 @@
KV: OfpFlowModArgs{"priority": 500, "table_id": 2, "cookie": 38268468, "flags": 12},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -627,7 +627,7 @@
KV: OfpFlowModArgs{"priority": 500, "table_id": 1, "cookie": 38268467, "flags": 12},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -642,7 +642,7 @@
KV: OfpFlowModArgs{"priority": 500, "table_id": 1, "cookie": 38268468, "flags": 14},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -657,7 +657,7 @@
KV: OfpFlowModArgs{"priority": 500, "table_id": 1, "cookie": 38268468, "flags": 12},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(4),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -672,7 +672,7 @@
KV: OfpFlowModArgs{"priority": 500, "table_id": 1, "cookie": 38268468, "flags": 12},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
},
@@ -686,7 +686,7 @@
KV: OfpFlowModArgs{"priority": 500, "table_id": 1, "cookie": 38268468, "flags": 12},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -707,7 +707,7 @@
KV: OfpFlowModArgs{"priority": 500, "table_id": 1},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
@@ -725,7 +725,7 @@
KV: OfpFlowModArgs{"priority": 500, "table_id": 1},
MatchFields: []*ofp.OfpOxmOfbField{
InPort(2),
- VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+ VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
VlanPcp(0),
EthType(0x800),
Ipv4Dst(0xe00a0a0a),
diff --git a/pkg/kafka/client.go b/pkg/kafka/client.go
index b3e20a3..77c529b 100755
--- a/pkg/kafka/client.go
+++ b/pkg/kafka/client.go
@@ -18,6 +18,7 @@
* release 2.9. It is no longer used for inter voltha container
* communication.
*/
+//nolint:staticcheck
package kafka
import (
diff --git a/pkg/kafka/sarama_client.go b/pkg/kafka/sarama_client.go
index 99168dc..d1a1a3a 100755
--- a/pkg/kafka/sarama_client.go
+++ b/pkg/kafka/sarama_client.go
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+//nolint:staticcheck
package kafka
import (
diff --git a/pkg/log/log.go b/pkg/log/log.go
index af5821a..8564602 100644
--- a/pkg/log/log.go
+++ b/pkg/log/log.go
@@ -503,13 +503,9 @@
}
}
- if strings.HasSuffix(packageName, ".init") {
- packageName = strings.TrimSuffix(packageName, ".init")
- }
+ packageName = strings.TrimSuffix(packageName, ".init")
- if strings.HasSuffix(fileName, ".go") {
- fileName = strings.TrimSuffix(fileName, ".go")
- }
+ fileName = strings.TrimSuffix(fileName, ".go")
return packageName, fileName, funcName, foundFrame.Line
}
diff --git a/pkg/mocks/kafka/kafka_client.go b/pkg/mocks/kafka/kafka_client.go
index b1f8da4..6d2bd1c 100644
--- a/pkg/mocks/kafka/kafka_client.go
+++ b/pkg/mocks/kafka/kafka_client.go
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+//nolint:staticcheck
package kafka
import (
diff --git a/pkg/platform/platform_test.go b/pkg/platform/platform_test.go
index 4b76497..960c6f3 100644
--- a/pkg/platform/platform_test.go
+++ b/pkg/platform/platform_test.go
@@ -19,14 +19,15 @@
import (
"context"
+ "math"
+ "reflect"
+ "testing"
+
fu "github.com/opencord/voltha-lib-go/v7/pkg/flows"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
- "math"
- "reflect"
- "testing"
)
func TestMkUniPortNum(t *testing.T) {
@@ -91,7 +92,9 @@
want uint32
}{
// TODO: Add test cases.
+ //nolint:staticcheck
{"IntfIDFromUniPortNum-1", args{portNum: 8096}, ((8096 / 65536) & 255)},
+ //nolint:staticcheck
{"IntfIDFromUniPortNum-2", args{portNum: 1024}, ((1024 / 65536) & 255)},
{"IntfIDFromUniPortNum-3", args{portNum: 66560}, ((66560 / 65536) & 255)},
{"IntfIDFromUniPortNum-4", args{portNum: 16712193}, ((16712193 / 65536) & 255)},
diff --git a/pkg/probe/probe_test.go b/pkg/probe/probe_test.go
index 846aa98..1b618be 100644
--- a/pkg/probe/probe_test.go
+++ b/pkg/probe/probe_test.go
@@ -18,12 +18,13 @@
import (
"context"
"encoding/json"
- "github.com/stretchr/testify/assert"
- "io/ioutil"
+ "io"
"net/http"
"net/http/httptest"
"testing"
"time"
+
+ "github.com/stretchr/testify/assert"
)
func TestServiceStatusString(t *testing.T) {
@@ -178,7 +179,7 @@
w := httptest.NewRecorder()
p.detailzFunc(w, req)
resp := w.Result()
- body, _ := ioutil.ReadAll(resp.Body)
+ body, _ := io.ReadAll(resp.Body)
assert.Equal(t, http.StatusOK, resp.StatusCode, "invalid status code for no services")
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"), "wrong content type")
diff --git a/pkg/stats/promserver_test.go b/pkg/stats/promserver_test.go
index 7332948..6db4dd0 100644
--- a/pkg/stats/promserver_test.go
+++ b/pkg/stats/promserver_test.go
@@ -18,7 +18,7 @@
import (
"context"
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"testing"
"time"
@@ -71,7 +71,7 @@
assert.Equal(t, 200, res.StatusCode)
- bodyBytes, err := ioutil.ReadAll(res.Body)
+ bodyBytes, err := io.ReadAll(res.Body)
require.NoError(t, err)
assert.Contains(t, string(bodyBytes), `voltha_rw_core_counters{counter="bus_write_errors_total"} 2`)
diff --git a/pkg/techprofile/tech_profile.go b/pkg/techprofile/tech_profile.go
index ed284b9..c3e202d 100644
--- a/pkg/techprofile/tech_profile.go
+++ b/pkg/techprofile/tech_profile.go
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+//nolint:staticcheck
package techprofile
import (
@@ -817,9 +817,7 @@
}
}
//add multicast GEM ports to dsGemPortAttributeList afterwards
- for k := range dsMulticastGemAttributeList {
- dsGemPortAttributeList = append(dsGemPortAttributeList, dsMulticastGemAttributeList[k])
- }
+ dsGemPortAttributeList = append(dsGemPortAttributeList, dsMulticastGemAttributeList...)
return &tp_pb.TechProfileInstance{
SubscriberIdentifier: uniPortName,