Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dirname ¶
Dirname returns a Command that strips the final component from each input path, equivalent to the Unix dirname(1) utility.
It matches GNU dirname's pure string semantics: trailing separators are removed, the last component is dropped, and remaining trailing separators are removed. Interior separators are preserved and "." / ".." are not resolved, so "a//b//c" yields "a//b" and "/foo/.." yields "/foo".
Example ¶
package main
import (
"fmt"
"github.com/gloo-foo/testable"
command "github.com/gloo-foo/cmd-dirname"
)
func main() {
lines, _ := testable.TestLines(command.Dirname(), "/usr/local/bin/script.sh\n/var/log/app.log\n")
for _, line := range lines {
fmt.Println(line)
}
}
Output: /usr/local/bin /var/log
Example (FilenameOnly) ¶
package main
import (
"fmt"
"github.com/gloo-foo/testable"
command "github.com/gloo-foo/cmd-dirname"
)
func main() {
lines, _ := testable.TestLines(command.Dirname(), "filename\n")
for _, line := range lines {
fmt.Println(line)
}
}
Output: .
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.