remove references to slices and to slice elements
Today I learned, while reading this newly published article, that you should never take the address of slices or of slice elements: https://utcc.utoronto.ca/~cks/space/blog/programming/GoSlicesVsPointers
So I greped for any slice element referencing:
$ grep -EIr '&[a-zA-Z]*\[[0-9]'
backend/agent/kea.go: paths := collectKeaAllowedLogs(&responses[0])
backend/server/restservice/machines_test.go: PrimaryCommInterrupted: &commInterrupted[0],
backend/server/restservice/machines_test.go: SecondaryCommInterrupted: &commInterrupted[1],
backend/server/restservice/machines_test.go: PrimaryCommInterrupted: &commInterrupted[0],
backend/server/restservice/hosts_test.go: err = dbmodel.AddAppToHost(db, &hosts[0], &apps[0], "config", 1)
backend/server/restservice/hosts_test.go: err = dbmodel.AddAppToHost(db, &hosts[0], &apps[1], "config", 1)
backend/server/apps/kea/service_test.go: err = dbmodel.AddService(db, &services[0])
backend/server/apps/kea/service_test.go: err = dbmodel.AddService(db, &services[1])
backend/server/apps/kea/statspuller.go: resultSet := &sr[0].Arguments.ResultSet
backend/server/database/model/service_test.go: PrimaryCommInterrupted: &commInterrupted[0],
backend/server/database/model/service_test.go: SecondaryCommInterrupted: &commInterrupted[1],
backend/server/database/model/host_test.go: err := AddAppToHost(db, &hosts[0], apps[0], "api", 1)
backend/server/database/model/host_test.go: err = AddAppToHost(db, &hosts[1], apps[0], "api", 1)
backend/server/database/model/host_test.go: err = AddAppToHost(db, &hosts[2], apps[1], "api", 1)
backend/server/database/model/host_test.go: err = AddAppToHost(db, &hosts[3], apps[1], "api", 1)
backend/server/database/model/host_test.go: err = AddAppToHost(db, &hosts[0], apps[0], "api", 123)
backend/server/database/model/host_test.go: err = AddAppToHost(db, &hosts[1], apps[1], "api", 123)
A false positive there in statspuller.go
. Ignore.
It's a potential problem of out of bounds memory access. The suggestion is to modify code to work with values instead of addresses or at least for a minimal effort to be done to prevent slice referencing in the future.