build/ci: Update Go to v1.24, golangci-lint to v1.64.6 and fix issues (#1804)

* build/ci: Update Go to v1.24, golangci-lint to v1.64.5 and fix issues

* Address shazbert's nitters

* linter/config: Fix new linter issue and use versionSize const

* Address gk's nitters and fix additional linter issue after rebase

* Address glorious nits

* staticcheck: Fix additional linter issues after upgrading to Go 1.24.1 and golangci-lint v1.64.6

Also addresses nits

* Improve testing, assertify usage and use common.ErrParsingWSField

* TestCreateNewStrategy: Replace must > should wording
This commit is contained in:
Adrian Gallagher
2025-03-10 16:33:55 +11:00
committed by GitHub
parent c086e281cf
commit d64d56f77c
114 changed files with 5080 additions and 9355 deletions

View File

@@ -1,9 +1,11 @@
package vm
import "testing"
import (
"testing"
)
func TestGctScriptManagerAutoLoadNonExisting(t *testing.T) {
var vms uint8 = 1
var vms uint64 = 1
g := &GctScriptManager{
config: &Config{
AutoLoad: []string{"non-existing"},

View File

@@ -11,7 +11,7 @@ import (
// New returns a new instance of VM
func (g *GctScriptManager) New() *VM {
if VMSCount.Len() >= int32(g.GetMaxVirtualMachines()) {
if VMSCount.Len() >= g.GetMaxVirtualMachines() {
if g.config.Verbose {
log.Warnf(log.GCTScriptMgr, "GCTScript MaxVirtualMachines (%v) hit, unable to start further instances",
g.GetMaxVirtualMachines())

View File

@@ -15,7 +15,7 @@ const (
type Config struct {
Enabled bool `json:"enabled"`
ScriptTimeout time.Duration `json:"timeout"`
MaxVirtualMachines uint8 `json:"max_virtual_machines"`
MaxVirtualMachines uint64 `json:"max_virtual_machines"`
AllowImports bool `json:"allow_imports"`
AutoLoad []string `json:"auto_load"`
Verbose bool `json:"verbose"`

View File

@@ -25,7 +25,7 @@ type GctScriptManager struct {
started int32
shutdown chan struct{}
// Optional values to override stored config ('nil' if not overridden)
MaxVirtualMachines *uint8
MaxVirtualMachines *uint64
}
// NewManager creates a new instance of script manager
@@ -83,7 +83,7 @@ func (g *GctScriptManager) run(wg *sync.WaitGroup) {
}
// GetMaxVirtualMachines returns the max number of VMs to create
func (g *GctScriptManager) GetMaxVirtualMachines() uint8 {
func (g *GctScriptManager) GetMaxVirtualMachines() uint64 {
if g.MaxVirtualMachines != nil {
return *g.MaxVirtualMachines
}

View File

@@ -78,13 +78,13 @@ func TestGctScriptManagerGetMaxVirtualMachines(t *testing.T) {
config *Config
started int32
shutdown chan struct{}
MaxVirtualMachines *uint8
MaxVirtualMachines *uint64
}
var value uint8 = 6
var value uint64 = 6
tests := []struct {
name string
fields fields
want uint8
want uint64
}{
{
name: "get from config",

View File

@@ -276,14 +276,14 @@ func (vm *VM) getHash() string {
}
func (vmc *vmscount) add() {
atomic.AddInt32((*int32)(vmc), 1)
atomic.AddUint64((*uint64)(vmc), 1)
}
func (vmc *vmscount) remove() {
atomic.AddInt32((*int32)(vmc), -1)
atomic.AddUint64((*uint64)(vmc), ^uint64(0))
}
// Len() returns current length vmscount
func (vmc *vmscount) Len() int32 {
return atomic.LoadInt32((*int32)(vmc))
func (vmc *vmscount) Len() uint64 {
return atomic.LoadUint64((*uint64)(vmc))
}

View File

@@ -12,9 +12,9 @@ import (
)
const (
maxTestVirtualMachines uint8 = 30
testVirtualMachineTimeout = time.Minute
scriptName = "1D01TH0RS3.gct"
maxTestVirtualMachines uint64 = 30
testVirtualMachineTimeout = time.Minute
scriptName = "1D01TH0RS3.gct"
)
var (
@@ -569,7 +569,7 @@ func TestVMCount(t *testing.T) {
}
}
func configHelper(enabled, imports bool, maxVMs uint8) *Config {
func configHelper(enabled, imports bool, maxVMs uint64) *Config {
return &Config{
Enabled: enabled,
AllowImports: imports,

View File

@@ -12,7 +12,7 @@ const (
// DefaultTimeoutValue default timeout value for virtual machines
DefaultTimeoutValue = 30 * time.Second
// DefaultMaxVirtualMachines max number of virtual machines that can be loaded at one time
DefaultMaxVirtualMachines uint8 = 10
DefaultMaxVirtualMachines uint64 = 10
// TypeLoad text to display in script_event table when a VM is loaded
TypeLoad = "load"
@@ -31,7 +31,7 @@ const (
StatusFailure = "failure"
)
type vmscount int32
type vmscount uint64
var (
pool = &sync.Pool{New: func() interface{} { return new(tengo.Script) }}