Depth returns the depth of the Options in the hierarchy. The main Options has a depth of 0, its child has a depth of 1, and so on.
()
| 78 | // Depth returns the depth of the Options in the hierarchy. |
| 79 | // The main Options has a depth of 0, its child has a depth of 1, and so on. |
| 80 | func (o *Options) Depth() int { |
| 81 | depth := 0 |
| 82 | |
| 83 | for p := o.main; p != nil && p != o; p = p.child { |
| 84 | depth++ |
| 85 | } |
| 86 | |
| 87 | return depth |
| 88 | } |
| 89 | |
| 90 | // Get retrieves a value of the specified type from the options. |
| 91 | // If the key does not exist, it returns the provided default value. |