@@ -83,14 +83,14 @@ func File(path string) *Pipe {
83
83
// Each line of the output consists of a slash-separated path, starting with
84
84
// the initial directory. For example, if the directory looks like this:
85
85
//
86
- // test/
87
- // 1.txt
88
- // 2.txt
86
+ // test/
87
+ // 1.txt
88
+ // 2.txt
89
89
//
90
90
// the pipe's output will be:
91
91
//
92
- // test/1.txt
93
- // test/2.txt
92
+ // test/1.txt
93
+ // test/2.txt
94
94
func FindFiles (path string ) * Pipe {
95
95
var fileNames []string
96
96
walkFn := func (path string , info os.FileInfo , err error ) error {
@@ -119,7 +119,7 @@ func Get(URL string) *Pipe {
119
119
// be set, and if the file does exist, the pipe will have no error status. This
120
120
// can be used to do some operation only if a given file exists:
121
121
//
122
- // IfExists("/foo/bar").Exec("/usr/bin/something")
122
+ // IfExists("/foo/bar").Exec("/usr/bin/something")
123
123
func IfExists (path string ) * Pipe {
124
124
p := NewPipe ()
125
125
_ , err := os .Stat (path )
@@ -133,7 +133,7 @@ func IfExists(path string) *Pipe {
133
133
// path, one per line. path can be a glob expression, as for [filepath.Match].
134
134
// For example:
135
135
//
136
- // ListFiles("/data/*").Stdout()
136
+ // ListFiles("/data/*").Stdout()
137
137
//
138
138
// ListFiles does not recurse into subdirectories; use [FindFiles] instead.
139
139
func ListFiles (path string ) * Pipe {
@@ -212,7 +212,7 @@ func (p *Pipe) Basename() *Pipe {
212
212
return p .FilterLine (filepath .Base )
213
213
}
214
214
215
- // Bytes returns the contents of the pipe as a []] byte, or an error.
215
+ // Bytes returns the contents of the pipe as a []byte, or an error.
216
216
func (p * Pipe ) Bytes () ([]byte , error ) {
217
217
res , err := io .ReadAll (p )
218
218
if err != nil {
@@ -247,15 +247,15 @@ func (p *Pipe) Column(col int) *Pipe {
247
247
// This makes it convenient to write programs that take a list of paths on the
248
248
// command line. For example:
249
249
//
250
- // script.Args().Concat().Stdout()
250
+ // script.Args().Concat().Stdout()
251
251
//
252
252
// The list of paths could also come from a file:
253
253
//
254
- // script.File("filelist.txt").Concat()
254
+ // script.File("filelist.txt").Concat()
255
255
//
256
256
// Or from the output of a command:
257
257
//
258
- // script.Exec("ls /var/app/config/").Concat().Stdout()
258
+ // script.Exec("ls /var/app/config/").Concat().Stdout()
259
259
//
260
260
// Each input file will be closed once it has been fully read. If any of the
261
261
// files can't be opened or read, Concat will simply skip these and carry on,
@@ -403,7 +403,7 @@ func (p *Pipe) Exec(cmdLine string) *Pipe {
403
403
// This is mostly useful for substituting data into commands using Go template
404
404
// syntax. For example:
405
405
//
406
- // ListFiles("*").ExecForEach("touch {{.}}").Wait()
406
+ // ListFiles("*").ExecForEach("touch {{.}}").Wait()
407
407
func (p * Pipe ) ExecForEach (cmdLine string ) * Pipe {
408
408
if p .Error () != nil {
409
409
return p
@@ -420,7 +420,7 @@ func (p *Pipe) ExecForEach(cmdLine string) *Pipe {
420
420
if err != nil {
421
421
return err
422
422
}
423
- // strings.Fields doesn't handle quotes
423
+ // strings.Fields doesn't handle quotes
424
424
args , ok := shell .Split (cmdLine .String ())
425
425
if ! ok {
426
426
return fmt .Errorf ("unbalanced quotes or backslashes in [%s]" , cmdLine .String ())
@@ -523,15 +523,15 @@ func (p *Pipe) First(n int) *Pipe {
523
523
//
524
524
// For example, we could take a common shell pipeline like this:
525
525
//
526
- // sort input.txt |uniq -c |sort -rn
526
+ // sort input.txt |uniq -c |sort -rn
527
527
//
528
528
// and replace it with:
529
529
//
530
- // File("input.txt").Freq().Stdout()
530
+ // File("input.txt").Freq().Stdout()
531
531
//
532
532
// Or to get only the ten most common lines:
533
533
//
534
- // File("input.txt").Freq().First(10).Stdout()
534
+ // File("input.txt").Freq().First(10).Stdout()
535
535
//
536
536
// Like Unix uniq(1), Freq right-justifies its count values in a column for
537
537
// readability, padding with spaces if necessary.
@@ -828,9 +828,9 @@ func (p *Pipe) WithError(err error) *Pipe {
828
828
// [Pipe.Do], [Pipe.Get], or [Pipe.Post]. For example, to make a request using
829
829
// a client with a timeout:
830
830
//
831
- // NewPipe().WithHTTPClient(&http.Client{
832
- // Timeout: 10 * time.Second,
833
- // }).Get("https://example.com").Stdout()
831
+ // NewPipe().WithHTTPClient(&http.Client{
832
+ // Timeout: 10 * time.Second,
833
+ // }).Get("https://example.com").Stdout()
834
834
func (p * Pipe ) WithHTTPClient (c * http.Client ) * Pipe {
835
835
p .httpClient = c
836
836
return p
0 commit comments