chore(lint): modernize Go (#7536)

Use modern Go constructs through the modernize analyzer from the
golang.org/x/tools package.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
Ville Vesilehto
2025-09-10 23:08:27 +03:00
committed by GitHub
parent afdd41a266
commit 39abf5aeba
48 changed files with 150 additions and 193 deletions

View File

@@ -239,7 +239,7 @@ func (dns *dnsControl) EndpointSliceLatencyRecorder() *object.EndpointLatencyRec
}
}
func podIPIndexFunc(obj interface{}) ([]string, error) {
func podIPIndexFunc(obj any) ([]string, error) {
p, ok := obj.(*object.Pod)
if !ok {
return nil, errObj
@@ -247,7 +247,7 @@ func podIPIndexFunc(obj interface{}) ([]string, error) {
return []string{p.PodIP}, nil
}
func svcIPIndexFunc(obj interface{}) ([]string, error) {
func svcIPIndexFunc(obj any) ([]string, error) {
svc, ok := obj.(*object.Service)
if !ok {
return nil, errObj
@@ -257,7 +257,7 @@ func svcIPIndexFunc(obj interface{}) ([]string, error) {
return idx, nil
}
func svcExtIPIndexFunc(obj interface{}) ([]string, error) {
func svcExtIPIndexFunc(obj any) ([]string, error) {
svc, ok := obj.(*object.Service)
if !ok {
return nil, errObj
@@ -267,7 +267,7 @@ func svcExtIPIndexFunc(obj interface{}) ([]string, error) {
return idx, nil
}
func svcNameNamespaceIndexFunc(obj interface{}) ([]string, error) {
func svcNameNamespaceIndexFunc(obj any) ([]string, error) {
s, ok := obj.(*object.Service)
if !ok {
return nil, errObj
@@ -275,7 +275,7 @@ func svcNameNamespaceIndexFunc(obj interface{}) ([]string, error) {
return []string{s.Index}, nil
}
func epNameNamespaceIndexFunc(obj interface{}) ([]string, error) {
func epNameNamespaceIndexFunc(obj any) ([]string, error) {
s, ok := obj.(*object.Endpoints)
if !ok {
return nil, errObj
@@ -283,7 +283,7 @@ func epNameNamespaceIndexFunc(obj interface{}) ([]string, error) {
return []string{s.Index}, nil
}
func epIPIndexFunc(obj interface{}) ([]string, error) {
func epIPIndexFunc(obj any) ([]string, error) {
ep, ok := obj.(*object.Endpoints)
if !ok {
return nil, errObj
@@ -291,7 +291,7 @@ func epIPIndexFunc(obj interface{}) ([]string, error) {
return ep.IndexIP, nil
}
func svcImportNameNamespaceIndexFunc(obj interface{}) ([]string, error) {
func svcImportNameNamespaceIndexFunc(obj any) ([]string, error) {
s, ok := obj.(*object.ServiceImport)
if !ok {
return nil, errObj
@@ -299,7 +299,7 @@ func svcImportNameNamespaceIndexFunc(obj interface{}) ([]string, error) {
return []string{s.Index}, nil
}
func mcEpNameNamespaceIndexFunc(obj interface{}) ([]string, error) {
func mcEpNameNamespaceIndexFunc(obj any) ([]string, error) {
mcEp, ok := obj.(*object.MultiClusterEndpoints)
if !ok {
return nil, errObj
@@ -647,12 +647,12 @@ func (dns *dnsControl) GetNamespaceByName(name string) (*object.Namespace, error
return ns, nil
}
func (dns *dnsControl) Add(obj interface{}) { dns.updateModified() }
func (dns *dnsControl) Delete(obj interface{}) { dns.updateModified() }
func (dns *dnsControl) Update(oldObj, newObj interface{}) { dns.detectChanges(oldObj, newObj) }
func (dns *dnsControl) Add(obj any) { dns.updateModified() }
func (dns *dnsControl) Delete(obj any) { dns.updateModified() }
func (dns *dnsControl) Update(oldObj, newObj any) { dns.detectChanges(oldObj, newObj) }
// detectChanges detects changes in objects, and updates the modified timestamp
func (dns *dnsControl) detectChanges(oldObj, newObj interface{}) {
func (dns *dnsControl) detectChanges(oldObj, newObj any) {
// If both objects have the same resource version, they are identical.
if newObj != nil && oldObj != nil && (oldObj.(meta.Object).GetResourceVersion() == newObj.(meta.Object).GetResourceVersion()) {
return
@@ -771,7 +771,7 @@ func multiclusterEndpointsEquivalent(a, b *object.MultiClusterEndpoints) bool {
// serviceModified checks the services passed for changes that result in changes
// to internal and or external records. It returns two booleans, one for internal
// record changes, and a second for external record changes
func serviceModified(oldObj, newObj interface{}) (intSvc, extSvc bool) {
func serviceModified(oldObj, newObj any) (intSvc, extSvc bool) {
if oldObj != nil && newObj == nil {
// deleted service only modifies external zone records if it had external ips
return true, len(oldObj.(*object.Service).ExternalIPs) > 0
@@ -825,7 +825,7 @@ func serviceModified(oldObj, newObj interface{}) (intSvc, extSvc bool) {
// serviceImportEquivalent checks if the update to a ServiceImport is something
// that matters to us or if they are effectively equivalent.
func serviceImportEquivalent(oldObj, newObj interface{}) bool {
func serviceImportEquivalent(oldObj, newObj any) bool {
if oldObj != nil && newObj == nil {
return false
}