The error states that the category is an array instead of just a string.
Your current definition:
type Post struct { ID primitive.ObjectID `json:"_id" bson:"_id,omitempty"` Title *string `json:"title" bson:"title"` Slug *string `json:"slug" bson:"slug"` Content []map[string]interface{} `json:"content" bson:"content,omitempty"` Category *string `json:"category" bson:"category,omitempty"`}Should look like:
type Post struct { ID primitive.ObjectID `json:"_id" bson:"_id,omitempty"` Title *string `json:"title" bson:"title"` Slug *string `json:"slug" bson:"slug"` Content []map[string]interface{} `json:"content" bson:"content,omitempty"` Category []*string `json:"category" bson:"category,omitempty"`}Where Category []*string might still need some tweaking:The pointer to string could also just be a string.
(Not knowing this return from Mongo and not having one running to test):
Another option is that the category is a byte array, and that the type has to be []byte.