MCPcopy Index your code
hub / github.com/bracesdev/errtrace / pipes

Method pipes

tree.go:235–247  ·  view source on GitHub ↗

pipes draws the "| | |" pipes prefix. path is a slice of indexes leading to the current node. For example, the path [1, 3, 2] says that the current node is the 2nd child of the 3rd child of the 1st child of the root. last is the last "|" component in this grouping; it'll normally be "| " or "+- "

(path []int, last string)

Source from the content-addressed store, hash-verified

233// Note that for cases where path[1] == 0,
234// we don't draw a pipe if len(path) > 2.
235func (p *treeWriter) pipes(path []int, last string) {
236 for depth, idx := range path {
237 if depth == len(path)-1 {
238 p.writeString(last)
239 } else if idx == 0 {
240 // First child of the parent at this layer.
241 // Nothing to connect to above us.
242 p.writeString(" ")
243 } else {
244 p.writeString("| ")
245 }
246 }
247}
248
249func (p *treeWriter) writeString(s string) {
250 _, err := io.WriteString(p.W, s)

Callers 1

writeTraceMethod · 0.95

Calls 1

writeStringMethod · 0.95

Tested by

no test coverage detected