From 9b24184730d65f2ee67acbbd1748947791bd5edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20=C5=BBak?= Date: Mon, 19 Dec 2022 11:53:43 +0100 Subject: [PATCH] fix(inputs.mysql): Revert slice declarations with non-zero initial length (#12409) Co-authored-by: Pawel Zak --- plugins/inputs/mysql/mysql.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/inputs/mysql/mysql.go b/plugins/inputs/mysql/mysql.go index 9045855fe..9e809884c 100644 --- a/plugins/inputs/mysql/mysql.go +++ b/plugins/inputs/mysql/mysql.go @@ -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