There are two ways to reset a buffer that with content ( length not equal zero ). You can use either Reset() or Truncate() methods found in the bytes.NewBuffer() function. The following example demonstrates how to create a buffer, check the size and capacity before and after clearing the buffer content.

By Adam Ng

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.