KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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: $ 6g test.go && 6l -o test test.6 && ./test {}
Tags (comma-separated)
Save Edits
Cancel