Standard library / text/template/parse

text/template/parse.PipeNode.CopyPipe()

CopyPipe copies the pipeline, retaining a typed result. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (p *PipeNode) CopyPipe() *PipeNode

Return Value

*PipeNode

CopyPipe copies the pipeline, retaining a typed result.

Working Example

Example Snippetgo
package main
import (  "fmt"  "text/template/parse")
func tree(s string) *parse.Tree {  t := parse.New("demo")  t.Mode = parse.ParseComments | parse.SkipFuncCheck  _, e := t.Parse(s, "", "", map[string]*parse.Tree{})  if e != nil {    panic(e)  }  return t}func action(s string) *parse.ActionNode { return tree(s).Root.Nodes[0].(*parse.ActionNode) }
func main() {  t := tree("{{. | printf \"%s\"}}")  n := t.Root.Nodes[0].(*parse.ActionNode).Pipe  c := n.CopyPipe()  fmt.Println(c != n && c.Cmds[0] != n.Cmds[0] && c.String() == n.String())}
Go Reference