If sending empty string the value gets not binded



I am using the echo.bind to bind data to struct. Something like this:

if err := c.Bind(u); err != nil {
    return echo.NewHTTPError(http.StatusBadRequest, "Malformed data received, try again please!")

The struct looks like this:

type User struct {
	ID     uint
	Name   string `gorm:"size:255" json:"name,omitempty"`
	Avatar string `gorm:"size:150" json:"avatar,omitempty"`

I am sending a PUT request to an endpoint, the json is structured like following:

{"name":"John Doe"}

This one works just fine, so the “John Doe” gets binded to the name and then I can save it to the database without any problems.

But if I send an empty name, like this:


The data gets not binded at all and the value gets just straight ignored.

Maybe this is a common thing in go and not related to echo itself, but I was just curious on how to have the empty value binded or maybe the struct needs changes to accept empty string.
Tried removing the “omitempty” from the struct for the name property, but the empty string is still ignored.
Could you point me into the right direction?


Well, it is the database orm which is not working correctly.
False alarm for this, you can remove.