fix(inputs.mysql): Revert slice declarations with non-zero initial length (#12409)

Co-authored-by: Pawel Zak <Pawel Zak>
This commit is contained in:
Paweł Żak 2022-12-19 11:53:43 +01:00 committed by GitHub
parent 37db046e06
commit 9b24184730
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -607,13 +607,12 @@ func (m *Mysql) gatherSlaveStatuses(db *sql.DB, serv string, acc telegraf.Accumu
return err
}
vals := make([]sql.RawBytes, 0, len(cols))
valPtrs := make([]interface{}, 0, len(cols))
vals := make([]sql.RawBytes, len(cols))
valPtrs := make([]interface{}, len(cols))
// fill the array with sql.Rawbytes
for range cols {
rawBytes := sql.RawBytes{}
vals = append(vals, rawBytes)
valPtrs = append(valPtrs, &rawBytes)
for i := range vals {
vals[i] = sql.RawBytes{}
valPtrs[i] = &vals[i]
}
if err = rows.Scan(valPtrs...); err != nil {
return err