Skip to content

Commit e87eea0

Browse files
authored
exec go fix (#5406)
Signed-off-by: Fedor Partanskiy <fredprtnsk@gmail.com>
1 parent a4de027 commit e87eea0

267 files changed

Lines changed: 871 additions & 959 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/common/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,6 @@ func evaluateFileFlag(f **os.File) string {
152152
return path
153153
}
154154

155-
func out(a ...interface{}) {
155+
func out(a ...any) {
156156
fmt.Fprintln(outWriter, a...)
157157
}

cmd/cryptogen/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ func generate() {
420420
}
421421
}
422422

423-
func parseTemplate(input string, data interface{}) (string, error) {
423+
func parseTemplate(input string, data any) (string, error) {
424424
t, err := template.New("parse").Parse(input)
425425
if err != nil {
426426
return "", fmt.Errorf("Error parsing template: %s", err)
@@ -435,7 +435,7 @@ func parseTemplate(input string, data interface{}) (string, error) {
435435
return output.String(), nil
436436
}
437437

438-
func parseTemplateWithDefault(input, defaultInput string, data interface{}) (string, error) {
438+
func parseTemplateWithDefault(input, defaultInput string, data any) (string, error) {
439439
// Use the default if the input is an empty string
440440
if len(input) == 0 {
441441
input = defaultInput

cmd/osnadmin/main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,15 +1061,15 @@ var _ = Describe("osnadmin", func() {
10611061
})
10621062
})
10631063

1064-
func checkStatusOutput(output string, exit int, err error, expectedStatus int, expectedOutput interface{}) {
1064+
func checkStatusOutput(output string, exit int, err error, expectedStatus int, expectedOutput any) {
10651065
Expect(err).NotTo(HaveOccurred())
10661066
Expect(exit).To(Equal(0))
10671067
json, err := json.MarshalIndent(expectedOutput, "", "\t")
10681068
Expect(err).NotTo(HaveOccurred())
10691069
Expect(output).To(Equal(fmt.Sprintf("Status: %d\n%s\n", expectedStatus, string(json))))
10701070
}
10711071

1072-
func checkOutput(output string, exit int, err error, expectedOutput interface{}) {
1072+
func checkOutput(output string, exit int, err error, expectedOutput any) {
10731073
Expect(err).NotTo(HaveOccurred())
10741074
Expect(exit).To(Equal(0))
10751075
json, err := json.MarshalIndent(expectedOutput, "", "\t")

cmd/peer/main_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ func TestPluginLoadingFailure(t *testing.T) {
5757
"ENDORSERS_ESCC",
5858
"VALIDATORS_VSCC",
5959
} {
60-
plugin := plugin
6160
t.Run(plugin, func(t *testing.T) {
6261
cmd := exec.Command(peer, "node", "start")
6362
cmd.Env = []string{

common/channelconfig/standardvalues.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// DeserializeProtoValuesFromGroup deserializes the value for all values in a config group
18-
func DeserializeProtoValuesFromGroup(group *cb.ConfigGroup, protosStructs ...interface{}) error {
18+
func DeserializeProtoValuesFromGroup(group *cb.ConfigGroup, protosStructs ...any) error {
1919
sv, err := NewStandardValues(protosStructs...)
2020
if err != nil {
2121
logger.Panicf("This is a compile time bug only, the proto structures are somehow invalid: %s", err)
@@ -38,7 +38,7 @@ type StandardValues struct {
3838
// the same condition. NewStandard values will instantiate memory for all the proto
3939
// messages and build a lookup map from structure field name to proto message instance
4040
// This is a useful way to easily implement the Values interface
41-
func NewStandardValues(protosStructs ...interface{}) (*StandardValues, error) {
41+
func NewStandardValues(protosStructs ...any) (*StandardValues, error) {
4242
sv := &StandardValues{
4343
lookup: make(map[string]proto.Message),
4444
}
@@ -72,19 +72,19 @@ func (sv *StandardValues) Deserialize(key string, value []byte) (proto.Message,
7272

7373
func (sv *StandardValues) initializeProtosStruct(objValue reflect.Value) error {
7474
objType := objValue.Type()
75-
if objType.Kind() != reflect.Ptr {
75+
if objType.Kind() != reflect.Pointer {
7676
return fmt.Errorf("Non pointer type")
7777
}
7878
if objType.Elem().Kind() != reflect.Struct {
7979
return fmt.Errorf("Non struct type")
8080
}
8181

8282
numFields := objValue.Elem().NumField()
83-
for i := 0; i < numFields; i++ {
83+
for i := range numFields {
8484
structField := objType.Elem().Field(i)
8585
logger.Debugf("Processing field: %s\n", structField.Name)
8686
switch structField.Type.Kind() {
87-
case reflect.Ptr:
87+
case reflect.Pointer:
8888
fieldPtr := objValue.Elem().Field(i)
8989
if !fieldPtr.CanSet() {
9090
return fmt.Errorf("Cannot set structure field %s (unexported?)", structField.Name)

common/channelconfig/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ func TestMarshalEtcdRaftMetadata(t *testing.T) {
351351
inputCerts[i], _ = os.ReadFile(fmt.Sprintf("testdata/tls-client-%d.pem", i+1))
352352
}
353353

354-
for i := 0; i < len(inputCerts)-1; i++ {
354+
for i := range len(inputCerts) - 1 {
355355
require.NotEqual(t, outputCerts[i+1], outputCerts[i], "expected extracted certs to differ from each other")
356356
}
357357
}

common/crypto/expiration.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func certExpirationTime(pemBytes []byte) time.Time {
4242
}
4343

4444
// MessageFunc notifies a message happened with the given format, and can be replaced with Warnf or Infof of a logger.
45-
type MessageFunc func(format string, args ...interface{})
45+
type MessageFunc func(format string, args ...any)
4646

4747
// Scheduler invokes f after d time, and can be replaced with time.AfterFunc.
4848
type Scheduler func(d time.Duration, f func()) *time.Timer
@@ -104,7 +104,7 @@ func trackCertExpiration(rawCert []byte, certRole string, info MessageFunc, warn
104104
var ErrPubKeyMismatch = errors.New("public keys do not match")
105105

106106
// LogNonPubKeyMismatchErr logs an error which is not an ErrPubKeyMismatch error
107-
func LogNonPubKeyMismatchErr(log func(template string, args ...interface{}), err error, cert1DER, cert2DER []byte) {
107+
func LogNonPubKeyMismatchErr(log func(template string, args ...any), err error, cert1DER, cert2DER []byte) {
108108
cert1PEM := &pem.Block{Type: "CERTIFICATE", Bytes: cert1DER}
109109
cert2PEM := &pem.Block{Type: "CERTIFICATE", Bytes: cert2DER}
110110
log("Failed determining if public key of %s matches public key of %s: %s",

common/crypto/expiration_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,17 @@ func TestTrackExpiration(t *testing.T) {
9191
IdBytes: tlsCert.Cert,
9292
})
9393

94-
warnShouldNotBeInvoked := func(format string, args ...interface{}) {
94+
warnShouldNotBeInvoked := func(format string, args ...any) {
9595
t.Fatalf(format, args...)
9696
}
9797

9898
var formattedWarning string
99-
warnShouldBeInvoked := func(format string, args ...interface{}) {
99+
warnShouldBeInvoked := func(format string, args ...any) {
100100
formattedWarning = fmt.Sprintf(format, args...)
101101
}
102102

103103
var formattedInfo string
104-
infoShouldBeInvoked := func(format string, args ...interface{}) {
104+
infoShouldBeInvoked := func(format string, args ...any) {
105105
formattedInfo = fmt.Sprintf(format, args...)
106106
}
107107

@@ -225,7 +225,7 @@ func TestLogNonPubKeyMismatchErr(t *testing.T) {
225225
string(bobKeyPair.Cert)))
226226

227227
b := &bytes.Buffer{}
228-
f := func(template string, args ...interface{}) {
228+
f := func(template string, args ...any) {
229229
fmt.Fprintf(b, template, args...)
230230
}
231231

common/deliver/acl_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var _ = Describe("SessionAccessControl", func() {
7070
sac, err := deliver.NewSessionAC(fakeChain, envelope, fakePolicyChecker, "chain-id", expiresAt)
7171
Expect(err).NotTo(HaveOccurred())
7272

73-
for i := 0; i < 5; i++ {
73+
for range 5 {
7474
err = sac.Evaluate()
7575
Expect(err).NotTo(HaveOccurred())
7676
}

common/deliver/deliver_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ var _ = Describe("Deliver", func() {
369369
Expect(err).NotTo(HaveOccurred())
370370

371371
Expect(fakeResponseSender.SendBlockResponseCallCount()).To(Equal(5))
372-
for i := 0; i < 5; i++ {
372+
for i := range 5 {
373373
b, _, _, _ := fakeResponseSender.SendBlockResponseArgsForCall(i)
374374
Expect(b).To(Equal(&cb.Block{
375375
Header: &cb.BlockHeader{Number: 995 + uint64(i)},
@@ -393,7 +393,7 @@ var _ = Describe("Deliver", func() {
393393

394394
Expect(fakeBlocksSent.AddCallCount()).To(Equal(5))
395395
Expect(fakeBlocksSent.WithCallCount()).To(Equal(5))
396-
for i := 0; i < 5; i++ {
396+
for i := range 5 {
397397
Expect(fakeBlocksSent.AddArgsForCall(i)).To(BeNumerically("~", 1.0))
398398
labelValues := fakeBlocksSent.WithArgsForCall(i)
399399
Expect(labelValues).To(Equal([]string{

0 commit comments

Comments
 (0)