Exemple #1
0
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'
}
Exemple #2
0
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'
}