This is a Q&D workaround. A maintenance nightmare, but it works.
Sprintf("Hello"+"%[2]s", "World", "")
On Monday, January 31, 2011 at 7:46:59 PM UTC+8, Ondekoza wrote:
>
> The fmt-package has a convinent error report method.
>
> According to
>
> http://golang.org/pkg/fmt/
>
> a string printed with fmt.Printf will add
>
> Too many arguments: %!(EXTRA type=value)
> Printf("hi", "guys"): hi%!(EXTRA string=guys)
>
> to the output if too many variables are supplied.
>
> Now the following problem:
>
> I always retrieve three numbers as int's and a string from an external
> source that I want to print and that is beyond my control - that might
> or might not contain placeholders for the insertion of the three ints.
> When I call fmt.Sprintf(mystring, int1, int2, int3) and the number of
> %-placeholder does not match, I'll get the EXTRA-error. How can I
> count the number of replacer-items, so that I can call Printf with the
> correct number of arguments?
>
> Obviously I cannot count the '%', since the input string might contain
> '%' signs that are no replacers. Additionally I cannot guarantuee that
> the string from the external source does not
> contain '%!'.
>
> Can I disable/discard the error-message somehow?
>
> yours
> Stefan Schroeder
>
--
_Grab is hiring. Learn more at *https://grab.careers
<https://grab.careers/>*_
By communicating with Grab Inc and/or its
subsidiaries, associate companies and jointly controlled entities (“Grab
Group”), you are deemed to have consented to processing of your personal
data as set out in the Privacy Notice which can be viewed at
https://grab.com/privacy/ <https://grab.com/privacy/>
This email contains
confidential information and is only for the intended recipient(s). If you
are not the intended recipient(s), please do not disseminate, distribute or
copy this email and notify Grab Group immediately if you have received this
by mistake and delete this email from your system. Email transmission
cannot be guaranteed to be secure or error-free as any information therein
could be intercepted, corrupted, lost, destroyed, delayed or incomplete, or
contain viruses. Grab Group do not accept liability for any errors or
omissions in the contents of this email arises as a result of email
transmission. All intellectual property rights in this email and
attachments therein shall remain vested in Grab Group, unless otherwise
provided by law.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.