xargs.go
func (x *XargsFilter) RunFilter(arg Arg) error {
	items := append([]string(nil), x.args...)
	added := 0 // Bytes added to items since last execution.
	for s := range arg.In {
		if len(items) > len(x.args) {
			// See if we have hit a byte or arg limit.
			if len(items)-len(x.args) >= x.limitArgs ||
				added+1+len(s) >= x.limitBytes {
				err := runCommand(arg, x.command, items...)
				if err != nil {
					return err
				}
				items = items[0:len(x.args)]
				added = 0
			}
		}
		items = append(items, s)
		added += 1 + len(s)
	}
	if len(items) > len(x.args) {
		return runCommand(arg, x.command, items...)
	}
	return nil
}
func (x *XargsFilter) RunFilter(arg Arg) error {
	items := append([]string(nil), x.args...)
	added := 0 // Bytes added to items since last execution.
	for s := range arg.In {
		if len(items) > len(x.args) {
			// See if we have hit a byte or arg limit.
			if len(items)-len(x.args) >= x.limitArgs ||
				added+1+len(s) >= x.limitBytes {
				err := runCommand(arg, x.command, items...)
				if err != nil {
					return err
				}
				items = items[0:len(x.args)]
				added = 0
			}
		}
		items = append(items, s)
		added += 1 + len(s)
	}
	if len(items) > len(x.args) {
		return runCommand(arg, x.command, items...)
	}
	return nil
}
func ( x * XargsFilter ) RunFilter ( arg Arg ) error { items := append ( [ ] string ( nil ) , x . args ... ) added := 0 // Bytes added to items since last execution. for s := range arg . In { if len ( items ) > len ( x . args ) { // See if we have hit a byte or arg limit. if len ( items ) - len ( x . args ) >= x . limitArgs || added + 1 + len ( s ) >= x . limitBytes { err := runCommand ( arg , x . command , items ... ) if err != nil { return err } items = items [ 0 : len ( x . args ) ] added = 0 } } items = append ( items , s ) added += 1 + len ( s ) } if len ( items ) > len ( x . args ) { return runCommand ( arg , x . command , items ... ) } return nil }
// RunFilter implements the Filter interface: it reads a sequence of items
// from arg.In and passes them as arguments to "command args...".
RunFilter implements the Filter interface : it reads a sequence of items from arg . In and passes them as arguments to command args ... .