These are chat archives for gin-gonic/gin

6th
Jul 2017
Andrey Nering
@andreynering
Jul 06 2017 11:41
Just updated, and Gin is printing log to Stdout even when the Gin mode is set to gin.TestMode. Is this intentional?
kebeeyong
@kebeeyong
Jul 06 2017 12:31
@javierprovecho / 0 /
{
"_id" : ObjectId("58d9cf1cdf353f3d2f5951b4"),
"id" : "1",
"firstname" : "Kebe",
"lastname" : "Eyong",
"poll" : "Who is the Richest Man in the World"
}
/* 0 */ { "_id" : ObjectId("58d9cf1cdf353f3d2f5951b4"), "id" : "1", "firstname" : "Kebe", "lastname" : "Eyong", "poll" : "Who is the Richest Man in the World" }
@javierprovecho type Poll struct { //ID stringjson:"_id,omitempty"ID bson.ObjectIdjson:"id,omitempty" bson:"_id,omitempty"Firstname stringjson:"firstname,omitempty"Lastname stringjson:"lastname,omitempty"Poll stringjson:"poll,omitempty"// Address *Addressjson:"address,omitempty"}
type Poll struct {
//ID string json:"_id,omitempty"
ID bson.ObjectId json:"id,omitempty" bson:"_id,omitempty"
Firstname string json:"firstname,omitempty"
Lastname string json:"lastname,omitempty"
Poll string json:"poll,omitempty"
// Address *Address json:"address,omitempty"
}
Thomas Boerger
@tboerger
Jul 06 2017 12:56
You should provide the code properly formatted, if you don't know markdown formatting you can also use gist.github.com
kebeeyong
@kebeeyong
Jul 06 2017 13:51
ok
Thomas Boerger
@tboerger
Jul 06 2017 14:11
Instead of directly using the if you have to type cast it to a bson if
Id
Beside that you should use github instead of gopkg.in
And c.JSON already sets a json mime type
kebeeyong
@kebeeyong
Jul 06 2017 14:15
i don't understand
pls show me an example
cos im using c.json and i can see d output of all my polls
Thomas Boerger
@tboerger
Jul 06 2017 14:20
You can drop the lines with c.Writer.Header().Set
kebeeyong
@kebeeyong
Jul 06 2017 14:20
ok
done
when i navigate to http://localhost:5000/polls/1
i get the error not found
Thomas Boerger
@tboerger
Jul 06 2017 14:24
And you try to put the poll into a slice of polls
kebeeyong
@kebeeyong
Jul 06 2017 14:25
how do i do dat?
i'm still learning
trying to master the language
pls kindly assist me
Thomas Boerger
@tboerger
Jul 06 2017 14:25
poll := Poll{} is what you want
kebeeyong
@kebeeyong
Jul 06 2017 14:25
i will be very grateful
Thomas Boerger
@tboerger
Jul 06 2017 14:26
But I'm running out of time now, got to work
kebeeyong
@kebeeyong
Jul 06 2017 14:26
i hv a collection name called poll