SimpleSplit returns a TraversalSplit where the name lookup is the absolute part and the remainder is the relative part. Supported only for absolute traversals, and will panic if applied to a relative traversal. This can be used by applications that have a relatively-simple variable namespace where
()
| 140 | // namespace where only the top-level is directly populated in the scope, with |
| 141 | // everything else handled by relative lookups from those initial values. |
| 142 | func (t Traversal) SimpleSplit() TraversalSplit { |
| 143 | if t.IsRelative() { |
| 144 | panic("can't use SimpleSplit on a relative traversal") |
| 145 | } |
| 146 | return TraversalSplit{ |
| 147 | Abs: t[0:1], |
| 148 | Rel: t[1:], |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // RootName returns the root name for a absolute traversal. Will panic if |
| 153 | // called on a relative traversal. |