29

I was working in Google CLoud and all was fine.. but when I clone all my project in my PC, I have this messages in every JSON struct.

struct field tag bson:"edad" json:"edad, omitempty" not compatible with reflect.StructTag.Get: suspicious space in struct tag valuestructtag

This is my Struct

type Usuario struct {
    ID        bson.RawValue `bson:"_id" json:"id, omitempty"`
    Nombre    string        `bson:"nombre" json:"nombre, omitempty"`
    Apellidos string        `bson:"apellidos" json:"apellidos, omitempty"`
    Edad      int           `bson:"edad" json:"edad, omitempty"`
    Email     string        `bson:"email" json:"email"`
    Password  string        `bson:"password" json:"password, omitempty"`
}

What's wrong ?

Thanks

Elba Nanero
  • 507
  • 1
  • 4
  • 10

1 Answers1

45

Remove the space after the comma before omitempty, then the error message will go away.

bson:"password" json:"password,omitempty" (should be like this)

In addition, this is a warning not an error. You should still be able to run your project.

MahnoorAsghar
  • 135
  • 1
  • 5
Pradip Parmar
  • 551
  • 3
  • 5
  • 1
    The space after the comma before omitempty is not missing, it should be removed. The wording of the answer is misleading, but the answer is correct :) – MahnoorAsghar May 31 '22 at 08:40