boilerplate icon indicating copy to clipboard operation
boilerplate copied to clipboard

does builderplate code handle zero allocations correctly?

Open olifink opened this issue 3 years ago • 1 comments

Hi there, I just got started with Fiber today. My own experiments worked fine, but trying out this boilerplate app looked wrong. When entering a couple of user names and then doing a reload the list seem to be the same strings with varying length. That looks to me that the buffer is not handled correctly.

changing the following in database.go seems to fix it

func UserCreate(c *fiber.Ctx) error {
	user := &models.User{
		Name: utils.ImmutableString(c.FormValue("user")),
	}
//...

I just wanted to confirm that this is correct and the right place - and I'm not missing something blindingly obvious as a beginner

olifink avatar Jun 25 '21 12:06 olifink

I had the same problem, your solution worked for me also. BTW, ImmutableString is deprecated now and should be changed to CopyString.

ztcollazo avatar Jan 04 '22 19:01 ztcollazo