diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 056a4b4..2450326 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,6 +33,20 @@ jobs: - name: Build Docker image run: make docker-build + staticcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: WillAbides/setup-go-faster@v1.14.0 + with: + go-version-file: 'go.mod' + + - uses: dominikh/staticcheck-action@v1.3.1 + with: + version: latest + install-go: false + lint: runs-on: ubuntu-latest steps: diff --git a/.golangci.yml b/.golangci.yml index b2fe2c7..1034df2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -231,7 +231,6 @@ linters: - gofmt - govet - errcheck - - staticcheck - unused - gosimple - ineffassign diff --git a/factory/config.go b/factory/config.go index 372dab1..865ffcb 100644 --- a/factory/config.go +++ b/factory/config.go @@ -121,7 +121,7 @@ func (c *Config) Validate() (err error) { PIter.ProcMap[1] = common.GetProcId(x[0]) PIter.WaitMap[1], err = strconv.Atoi(x[1]) if err != nil { - return fmt.Errorf("Value is not converted to integer: %v\n", err) + return fmt.Errorf("value is not converted to integer: %v", err) } } if len(v1.Second) > 0 { @@ -129,7 +129,7 @@ func (c *Config) Validate() (err error) { PIter.ProcMap[2] = common.GetProcId(x[0]) PIter.WaitMap[2], err = strconv.Atoi(x[1]) if err != nil { - return fmt.Errorf("Value is not converted to integer: %v\n", err) + return fmt.Errorf("value is not converted to integer: %v", err) } } if len(v1.Third) > 0 { @@ -137,7 +137,7 @@ func (c *Config) Validate() (err error) { PIter.ProcMap[3] = common.GetProcId(x[0]) PIter.WaitMap[3], err = strconv.Atoi(x[1]) if err != nil { - return fmt.Errorf("Value is not converted to integer: %v\n", err) + return fmt.Errorf("value is not converted to integer: %v", err) } } if len(v1.Fourth) > 0 { @@ -145,7 +145,7 @@ func (c *Config) Validate() (err error) { PIter.ProcMap[4] = common.GetProcId(x[0]) PIter.WaitMap[4], err = strconv.Atoi(x[1]) if err != nil { - return fmt.Errorf("Value is not converted to integer: %v\n", err) + return fmt.Errorf("value is not converted to integer: %v", err) } } if len(v1.Fifth) > 0 { @@ -153,7 +153,7 @@ func (c *Config) Validate() (err error) { PIter.ProcMap[5] = common.GetProcId(x[0]) PIter.WaitMap[5], err = strconv.Atoi(x[1]) if err != nil { - return fmt.Errorf("Value is not converted to integer: %v\n", err) + return fmt.Errorf("value is not converted to integer: %v", err) } } if len(v1.Sixth) > 0 { @@ -161,7 +161,7 @@ func (c *Config) Validate() (err error) { PIter.ProcMap[6] = common.GetProcId(x[0]) PIter.WaitMap[6], err = strconv.Atoi(x[1]) if err != nil { - return fmt.Errorf("Value is not converted to integer: %v\n", err) + return fmt.Errorf("value is not converted to integer: %v", err) } } if len(v1.Seventh) > 0 { @@ -169,7 +169,7 @@ func (c *Config) Validate() (err error) { PIter.ProcMap[7] = common.GetProcId(x[0]) PIter.WaitMap[7], err = strconv.Atoi(x[1]) if err != nil { - return fmt.Errorf("Value is not converted to integer: %v\n", err) + return fmt.Errorf("value is not converted to integer: %v", err) } } v.PIterations[v1.Name] = PIter // add iterations in the custom profile diff --git a/factory/factory.go b/factory/factory.go index 93dda48..da7da30 100644 --- a/factory/factory.go +++ b/factory/factory.go @@ -47,7 +47,7 @@ func CheckConfigVersion() error { currentVersion := AppConfig.GetVersion() if currentVersion != GNBSIM_EXPECTED_CONFIG_VERSION { - return fmt.Errorf("config version is [%s], but expected is [%s].", + return fmt.Errorf("config version is [%s], but expected is [%s]", currentVersion, GNBSIM_EXPECTED_CONFIG_VERSION) } diff --git a/gnodeb/worker/gnbamfworker/worker.go b/gnodeb/worker/gnbamfworker/worker.go index 981b84d..4ac324f 100644 --- a/gnodeb/worker/gnbamfworker/worker.go +++ b/gnodeb/worker/gnbamfworker/worker.go @@ -28,7 +28,7 @@ func HandleMessage(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, pkt []byte, id uint64 case ngapType.NGAPPDUPresentInitiatingMessage: initiatingMessage := pdu.InitiatingMessage if initiatingMessage == nil { - return fmt.Errorf("Initiatiting Message is nil") + return fmt.Errorf("initiatiting Message is nil") } switch initiatingMessage.ProcedureCode.Value { case ngapType.ProcedureCodeDownlinkNASTransport: diff --git a/profile/profile.go b/profile/profile.go index 1d3f3c9..05ca368 100644 --- a/profile/profile.go +++ b/profile/profile.go @@ -55,7 +55,7 @@ func InitProfile(profile *profctx.Profile, summaryChan chan common.InterfaceMess gnb, err := factory.AppConfig.Configuration.GetGNodeB(profile.GnbName) if err != nil { - err = fmt.Errorf("Failed to fetch gNB context: %v", err) + err = fmt.Errorf("failed to fetch gNB context: %v", err) summary.ErrorList = append(summary.ErrorList, err) summaryChan <- summary return diff --git a/util/test/ngsetup.go b/util/test/ngsetup.go index 9399771..6675bec 100644 --- a/util/test/ngsetup.go +++ b/util/test/ngsetup.go @@ -17,7 +17,7 @@ const NgapPPID uint32 = 0x3c000000 func getNgapIp(amfIP, ranIP string, amfPort, ranPort int) (amfAddr, ranAddr *sctp.SCTPAddr, err error) { ips := []net.IPAddr{} if ip, err1 := net.ResolveIPAddr("ip", amfIP); err1 != nil { - err = fmt.Errorf("Error resolving address '%s': %v", amfIP, err1) + err = fmt.Errorf("error resolving address '%s': %v", amfIP, err1) return nil, nil, err } else { ips = append(ips, *ip) @@ -28,7 +28,7 @@ func getNgapIp(amfIP, ranIP string, amfPort, ranPort int) (amfAddr, ranAddr *sct } ips = []net.IPAddr{} if ip, err1 := net.ResolveIPAddr("ip", ranIP); err1 != nil { - err = fmt.Errorf("Error resolving address '%s': %v", ranIP, err1) + err = fmt.Errorf("error resolving address '%s': %v", ranIP, err1) return nil, nil, err } else { ips = append(ips, *ip) diff --git a/util/test/rawudp.go b/util/test/rawudp.go index e0121b4..94a8711 100644 --- a/util/test/rawudp.go +++ b/util/test/rawudp.go @@ -128,7 +128,7 @@ func BuildRawUdpIp(srcIP, dstIP string, srcPort, dstPort uint16, payload []byte) udplen := 8 + len(payload) totalLen := 20 + udplen if totalLen > 0xffff { - err = fmt.Errorf("message is too large to fit into a packet: %v > %v\n", totalLen, 0xffff) + err = fmt.Errorf("message is too large to fit into a packet: %v > %v", totalLen, 0xffff) return nil, err }