try doing magic with generics
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -35,6 +35,11 @@ type UserSecret struct {
|
||||
Permission
|
||||
}
|
||||
|
||||
// This method allows us to use an interface to avoid adding duplicate entries to a []Secret
|
||||
func (s Secret) GetId() int {
|
||||
return s.SecretId
|
||||
}
|
||||
|
||||
func (s *Secret) SaveSecret() (*Secret, error) {
|
||||
|
||||
var err error
|
||||
@@ -141,7 +146,12 @@ func SecretsGetAllowed(s *Secret, userId int) ([]UserSecret, error) {
|
||||
log.Println(debugPrint)
|
||||
|
||||
// Append the secrets to the query output, don't decrypt the secrets (we didn't SELECT them anyway)
|
||||
secretResults = append(secretResults, r)
|
||||
//secretResults = append(secretResults, r)
|
||||
|
||||
// Use generics and the GetID() method on the UserSecret struct
|
||||
// to avoid adding this element to the results
|
||||
// if there is already a secret with the same ID present
|
||||
secretResults = utils.AppendIfNotExists(secretResults, r)
|
||||
}
|
||||
log.Printf("SecretsGetAllowed retrieved '%d' results\n", len(secretResults))
|
||||
}
|
||||
|
Reference in New Issue
Block a user