When keyring is empty KeyRing.FirstKey returns nil (#25)

This commit is contained in:
wussler 2019-08-30 12:22:50 +02:00 committed by GitHub
parent 72e33612c4
commit 52ecc1ce36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -450,9 +450,12 @@ func FilterExpiredKeys(contactKeys []*KeyRing) (filteredKeys []*KeyRing, err err
// FirstKey returns a KeyRing with only the first key of the original one
func (keyRing *KeyRing) FirstKey() *KeyRing {
if len(keyRing.entities) == 0 {
return nil
}
newKeyRing := &KeyRing{}
newKeyRing.FirstKeyID = keyRing.FirstKeyID
newKeyRing.entities = keyRing.entities[:1]
return newKeyRing;
return newKeyRing
}