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") You could make a custom type which implements io.Writer and truncates at a given size, and pass it to fmt.Fprintf On Tuesday 6 February 2024 at 09:52:29 UTC fge...@gmail.com wrote: > C *nprintf(3) implementations stop the conversion when n is reached. > I couldn't find a similar functionality in the standard library, what > did I miss? > If there isn't any, any idea how to implement that without > reimplementing all format helpers? > thanks! > -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/966c0d89-1570-4837-bf5c-657c09ca43e4n%40googlegroups.com.