mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
add support for variable formatters
R=rsc DELTA=134 (75 added, 41 deleted, 18 changed) OCL=27245 CL=27247
This commit is contained in:
parent
f95da9a639
commit
3a7df4dde0
3 changed files with 91 additions and 57 deletions
|
|
@ -914,3 +914,17 @@ func NewValue(e interface {}) Value {
|
|||
*ap = value;
|
||||
return newValueAddr(typ, Addr(ap));
|
||||
}
|
||||
|
||||
// Indirect indirects one level through a value, if it is a pointer.
|
||||
// If not a pointer, the value is returned unchanged.
|
||||
// Useful when walking arbitrary data structures.
|
||||
func Indirect(v Value) Value {
|
||||
if v.Kind() == PtrKind {
|
||||
p := v.(PtrValue);
|
||||
if p.Get() == nil {
|
||||
return nil
|
||||
}
|
||||
v = p.Sub()
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue