I am trying to convert a Go struct to JSON using the json package but all I get is {}. I am certain it is something totally obvious but I don't see it.
package main import ( "fmt" "encoding/json" ) type User struct { name string } func main() { user := &User{name:"Frank"} b, err := json.Marshal(user) if err != nil { fmt.Printf("Error: %s", err) return; } fmt.Println(string(b)) }
Then when I try to run it I get this:
{}

Write your answer...

Never miss a post from Chris Gregori, when you sign up for Ednsquare.