On Tue, Feb 6, 2024 at 12:18 PM 'Brian Candler' via golang-nuts
<
golan...@googlegroups.com> 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 fmt.Sprintf() can't.
Though I can live with careful coding and not using Sprintf() in this
case, I just hoped possibly somebody else already thought about
needing that.
...
> You could make a custom type which implements io.Writer and truncates at a given size, and pass it to fmt.Fprintf
IIUC this sounds similar to what I'm asking for. How to use a limiting
io.Writer with fmt.Sprintf()? How would this limit fmt.Sprintf()'s
memory usage?