|
|
@ -6,7 +6,7 @@ import ( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Reset function creates new zero object for the target pointer
|
|
|
|
// Reset function creates new zero object for the target pointer
|
|
|
|
func Reset(target interface{}) { |
|
|
|
func Reset(target interface{}) (created bool) { |
|
|
|
|
|
|
|
|
|
|
|
type resetter interface { |
|
|
|
type resetter interface { |
|
|
|
Reset() |
|
|
|
Reset() |
|
|
@ -15,7 +15,7 @@ func Reset(target interface{}) { |
|
|
|
resettable, canReset := target.(resetter) |
|
|
|
resettable, canReset := target.(resetter) |
|
|
|
if canReset { |
|
|
|
if canReset { |
|
|
|
resettable.Reset() |
|
|
|
resettable.Reset() |
|
|
|
return |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
v := reflect.ValueOf(target) |
|
|
|
v := reflect.ValueOf(target) |
|
|
@ -27,4 +27,6 @@ func Reset(target interface{}) { |
|
|
|
zero := reflect.Zero(t) |
|
|
|
zero := reflect.Zero(t) |
|
|
|
|
|
|
|
|
|
|
|
v.Elem().Set(zero) |
|
|
|
v.Elem().Set(zero) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|