Example #1
1
func ExampleSprintf() {
	// Generates shell command to find number of go files on a remote machine
	host := "foo.com"
	findCmd := shell.Sprintf("find . -iname %s | wc -l", "*.go")
	remoteCmd := shell.Sprintf("ssh ubuntu@%s %s", host, findCmd)
	fmt.Println(remoteCmd)
	// Output: ssh [email protected] 'find . -iname '\''*.go'\'' | wc -l'
}
Example #2
1
func ExampleSprintf_StringSlice() {
	// Support for passing in a slice of arguments
	gitcmd := shell.Sprintf("git add %S", []string{"foo.go", "bar.go", "test data"})
	fmt.Println(gitcmd)
	// Output: git add foo.go bar.go 'test data'
}