Documentation
¶
Overview ¶
Package scoped provides a mapping from a string to any data type that is "scoped".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ParamValue ¶ added in v0.28.0
ParamValue is returned by Params.Iter()
type Params ¶
type Params struct {
Separator string
// contains filtered or unexported fields
}
Params provides a mapping from string to any data type that is "scoped":
- For every scope there is a map of string to data.
- Accessing a key triggers a search from the current scope up to the root scope, the first result found is returned.
Example: let's say the current Params hold:
Scope: "/": { "x":10, "y": 20, "z": 40 }
Scope: "/a": { "y": 30 }
Scope: "/a/b": { "x": 100 }
Params.Get("/a/b", "x") -> 100
Params.Get("/a/b", "y") -> 30
Params.Get("/a/b", "z") -> 40
Params.Get("/a/b", "w") -> Not found.
Notice that "/" (== ScopeSeparator constant) separates parts of the scope path, and the root scope is referred to as "/". There is no "empty" scope, and every scope name must start with a ScopeSeparator.
The Context object uses Params to store the normal hyperparameters (see `Context.GetParam` and `Context.SetParam`) and to store the graph hyperparameters (see `Context.GetGraphParam` and `Context.SetGraphParam`).
Usually there will be no need for the end user to use this.
func (*Params) Enumerate ¶
Enumerate enumerates all parameters stored in the scopedParams structure and calls the given closure with them.
func (*Params) Get ¶
Get retrieves the value for the given key in the given scope or any parent scope. E.g: Get("/a/b", "myKey") will search for "myKey" in scopes "/a/b", "/a" and "/" consecutively until "myKey" is found.
It returns the first value found if any, and whether some value was found.