%q
to quote a string in fmt.Sprintf
format specifiers GO-R400275}
76
77func (p ParseError) Error() string {
78 return fmt.Sprintf(`%s while parsing line "%s"`, p.Err, p.Line)79}
80
81func must(a int, err error) int {
37 })
38
39 mockErrorResponse := func(method string, endpoint string, message string, status int) {
40 response := fmt.Sprintf(`{"error":"%s"}`, message) 41 bcServer.AppendHandlers(
42 ghttp.CombineHandlers(
43 ghttp.VerifyRequest(method, endpoint),
28 Expect(watch).To(gbytes.Say("succeeded"))
29
30 watch = fly("pin-resource", "-r", inPipeline("some-resource"), "-v", fmt.Sprintf(`version:%s`, someResourceV1), "-c", "some comment")
31 Expect(watch).To(gbytes.Say(fmt.Sprintf("pinned '%s' with version {\"version\":\"%s\"}\n", inPipeline("some-resource"), someResourceV1)))32 Expect(watch).To(gbytes.Say("pin comment 'some comment' is saved"))
33
34 watch = fly("trigger-job", "-j", inPipeline("some-passing-job"), "-w")
78func printableCommand(args []string) string {
79 for i, arg := range args {
80 if strings.Contains(arg, " ") {
81 args[i] = fmt.Sprintf(`"%s"`, arg)82 }
83 }
84
51 }
52
53 if short != "" {
54 template += fmt.Sprintf(" -s \"%s\"", short)55 }
56
57 snippet += template + "\n"
%q
is same as "%s"
.
str := fmt.Sprintf("str: "%s"", "Hello World")
// str => str: "Hello World"
str := fmt.Sprintf("str: %q", "Hello World")
// str => str: "Hello World"