(This time reply to list. Sorry Brian.)
On Tue, Feb 6, 2024 at 3:03 PM 'Brian Candler' via golang-nuts
wrote:
>
> > Thanks! In addition to that, It also helps with code with upper limit
> > memory-requirement, which fmt.Sprintf() can't.
>
> If you're processing data from untrusted sources, then
> Thanks! In addition to that, It also helps with code with upper limit
> memory-requirement, which fmt.Sprintf() can't.
If you're processing data from untrusted sources, then you probably ought
to validate it first.
> How to use a limiting
> io.Writer with fmt.Sprintf()? How would this limit
On Tue, Feb 6, 2024 at 12:18 PM 'Brian Candler' via golang-nuts
wrote:
>
> The C functions are mainly there to prevent overrunning already-allocated
> buffers, which isn't an issue with Go.
Thanks! In addition to that, It also helps with code with upper limit
memory-requirement, which
The C functions are mainly there to prevent overrunning already-allocated
buffers, which isn't an issue with Go.
You could truncate the response:
a := fmt.Sprintf("%s", "Blah blah blah")[0:10]
You could use suitable precision specifiers:
a := fmt.Sprintf("%.10s", "Blah blah blah")