Quantcast
Channel: How can I merge two structs in Golang? - Stack Overflow
Viewing all articles
Browse latest Browse all 6

How can I merge two structs in Golang?

$
0
0

I have two json-marshallable anonymous structs.

a := struct {    Name string `json:"name"`}{"my name"}b := struct {    Description string `json:"description"`}{"my description"}

Is there any way to merge them into json to get something like that:

{"name":"my name","description":"my description"}

Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles



Latest Images