Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AnchorableTypes []anchorableType
AnchorableTypes contains all non-native types that can be anchorable. See AddAnchorableStructType to add a new type to it.
Functions ¶
func AddAnchorableStructType ¶
AddAnchorableStructType declares a struct type as anchorable. fn is a function allowing to return a unique and identifiable instance of the struct type.
fn has to have the following signature:
func (nextAnchor int) TYPE
TYPE is the struct type to make anchorable and nextAnchor is an index to allow to differentiate several instances of the same type.
For example, the time.Time type which is anchorable by default, is declared as:
AddAnchorableStructType(func (nextAnchor int) time.Time { return time.Unix(math.MaxInt64-1000424443-int64(nextAnchor), 42) })
Just as a note, the 1000424443 constant allows to avoid to flirt with the math.MaxInt64 extreme limit and so avoid possible collision with real world values.
It returns an error if the provided fn is not a function or if it has not the expected signature (see above).
Types ¶
type Info ¶
Info gathers all anchors information.
func (*Info) AddAnchor ¶
AddAnchor anchors a new operator op, with type typ then returns the anchor value.
func (*Info) DoAnchorsPersist ¶
DoAnchorsPersist returns true if anchors are persistent across tests.
func (*Info) ResetAnchors ¶
ResetAnchors removes all anchors if persistence is disabled or force is true.
func (*Info) ResolveAnchor ¶
ResolveAnchor checks whether the passed value matches an anchored operator or not. If yes, this operator is returned with true. If no, the value is returned as is with false.
func (*Info) SetAnchorsPersist ¶
SetAnchorsPersist enables or disables anchors persistence.