Use named returns for the code style consistency

This commit is contained in:
Nikita Tokarchuk
2020-07-13 03:12:39 +02:00
parent 9cf3551c20
commit 72e74a65b6
23 changed files with 145 additions and 146 deletions
+7 -5
View File
@@ -7,11 +7,11 @@ import (
)
// GetProtection function finds protection field in the source document otherwise returns nil
func GetProtection(source interface{}) *protection.Key {
func GetProtection(source interface{}) (key *protection.Key) {
v := reflect.ValueOf(source)
if v.Kind() != reflect.Ptr || v.IsNil() {
return nil
return
}
el := v.Elem()
@@ -25,14 +25,16 @@ func GetProtection(source interface{}) *protection.Key {
switch field.Interface().(type) {
case *protection.Key:
return field.Interface().(*protection.Key)
key = field.Interface().(*protection.Key)
case protection.Key:
ptr := field.Addr()
return ptr.Interface().(*protection.Key)
key = ptr.Interface().(*protection.Key)
default:
continue
}
return
}
return nil
return
}
+1 -1
View File
@@ -14,7 +14,7 @@ type Primary struct {
}
// GetID returns an _id
func (p *Primary) GetID() primitive.D {
func (p *Primary) GetID() (id primitive.D) {
return p.ID
}
+1 -1
View File
@@ -14,7 +14,7 @@ type Primary struct {
}
// GetID returns an _id
func (p *Primary) GetID() primitive.ObjectID {
func (p *Primary) GetID() (id primitive.ObjectID) {
return p.ID
}
+1 -1
View File
@@ -12,7 +12,7 @@ type Primary struct {
}
// GetID returns an _id
func (p *Primary) GetID() string {
func (p *Primary) GetID() (id string) {
return p.ID
}