mirror of
https://github.com/mainnika/mongox-go-driver.git
synced 2026-05-22 15:53:36 +00:00
Use named returns for the code style consistency
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user