How to print struct variables in console?
@lebyy▲ 0 net votes
Problem: How can I print (to the console) the Id , Title , Name , etc. of this struct in Golang? type Project struct { Id int64 json:"project_id" Title string json:"title" Name string `json:&qu Fix (from the top answer): To print the name of the fields in a struct: fmt.Printf("%+v\n", yourProject) From the fmt package : when printing structs, the plus flag ( %+v ) adds field names That supposes you have an instance of Project (in ' yourProject ') The article JSON and Go will give more details on how to retrieve the values from a JSON…