Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( PasteSerial pasteSerialFlag = true PasteNoSerial pasteSerialFlag = false )
Variables ¶
This section is empty.
Functions ¶
func Paste ¶
Paste merges input lines according to GNU paste semantics.
Flags:
- PasteSerial (-s): join every line of the stream into a single row.
- PasteDelimiter (-d): set the delimiter list cycled between joins.
In serial mode the whole stream collapses to one row whose lines are joined by the delimiter list (cycled byte by byte). In the default (parallel) mode a single input stream passes through unchanged: each line is its own row.
Example ¶
package main
import (
"fmt"
"github.com/gloo-foo/testable"
command "github.com/gloo-foo/cmd-paste"
)
func main() {
// Default (parallel) mode: each line of a single stream is its own row.
output, _ := testable.Test(command.Paste(), "alpha\nbeta\ngamma\n")
fmt.Print(output)
}
Output: alpha beta gamma
Example (Serial) ¶
package main
import (
"fmt"
"github.com/gloo-foo/testable"
command "github.com/gloo-foo/cmd-paste"
)
func main() {
// Serial mode (-s) joins every line into one tab-separated row.
output, _ := testable.Test(command.Paste(command.PasteSerial), "alpha\nbeta\ngamma\n")
fmt.Print(output)
}
Output: alpha beta gamma
Example (SerialDelimiter) ¶
package main
import (
"fmt"
"github.com/gloo-foo/testable"
command "github.com/gloo-foo/cmd-paste"
)
func main() {
// Serial mode with a delimiter list cycled between joins.
output, _ := testable.Test(command.Paste(command.PasteSerial, command.PasteDelimiter(",;")), "a\nb\nc\nd\n")
fmt.Print(output)
}
Output: a,b;c,d
Types ¶
type PasteDelimiter ¶
type PasteDelimiter string
PasteDelimiter is the delimiter list joined between consecutive lines (-d). GNU paste treats the argument as a list of single-byte delimiters cycled in order between joins; a single-character value behaves as one fixed separator.
Click to show internal directories.
Click to hide internal directories.