github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/types/generic/index.go (about) 1 package generic 2 3 import ( 4 "bytes" 5 "strings" 6 7 "github.com/lmorg/murex/lang" 8 ) 9 10 func index(p *lang.Process, params []string) error { 11 cRecords := make(chan []string, 1) 12 13 go func() { 14 err := p.Stdin.ReadLine(func(b []byte) { 15 cRecords <- rxWhitespace.Split(string(bytes.TrimSpace(b)), -1) 16 }) 17 if err != nil { 18 p.Stderr.Writeln([]byte(err.Error())) 19 } 20 close(cRecords) 21 }() 22 23 marshaller := func(s []string) (b []byte) { 24 b = []byte(strings.Join(s, "\t")) 25 return 26 } 27 28 return lang.IndexTemplateTable(p, params, cRecords, marshaller) 29 }