append
possibly assigns to a wrong variable CRT-D0001 959
960 // Add some more new validator to the base validator.
961 validatosToAddInTest := validators(10000)
962 allValidators := append(initialSetOfValidators, validatosToAddInTest...) 963
964 // shuffle validators.
965 rand.Seed(time.Now().UnixNano())
913
914 // Add some more new validator to the base validator.
915 validatosToAddInTest := validators(10000)
916 allValidators := append(initialSetOfValidators, validatosToAddInTest...) 917
918 // shuffle validators.
919 rand.Seed(time.Now().UnixNano())
80 message := signed.Message
81 newCredentials := make([]byte, executionToBLSPadding)
82 newCredentials[0] = params.BeaconConfig().ETH1AddressWithdrawalPrefixByte
83 val.WithdrawalCredentials = append(newCredentials, message.ToExecutionAddress...) 84 err = st.UpdateValidatorAtIndex(message.ValidatorIndex, val)
85 return st, err
86}
161 b.sharedFieldReferences[types.HistoricalSummaries] = stateutil.NewRef(1)
162 }
163
164 b.historicalSummaries = append(summaries, summary)165 b.markFieldAsDirty(types.HistoricalSummaries)
166 return nil
167}
138 b.sharedFieldReferences[types.HistoricalRoots] = stateutil.NewRef(1)
139 }
140
141 b.historicalRoots = append(roots, root)142 b.markFieldAsDirty(types.HistoricalRoots)
143 return nil
144}
The builtin function append
returns the updated slice after the append operation.
This resulting slice is usually assigned back to the same variable that contained
the original slice to which new values were appended.
x = []int{1, 3, 5}
append(x, 7) // returns the value []int{1, 3, 5, 7}. This is usually assigned back to x
x := []int{}
y := []int{}
x = append(y, 1) // possibly wrong
x = []int{1, 3, 5}
x = append(x, 7)
x := []int{}
y := []int{}
y = append(y, 1) // append 1 to y