fatih / structs

Utilities for Go structs

Home Page:http://godoc.org/github.com/fatih/structs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I get empty return for this

suntong opened this issue · comments

Can anyone help me to see what's wrong with the following line please?

https://github.com/suntong/lang/blob/820cf694de6b099256f429b9fff91265461eef25/lang/Go/src/ds/structs_example.go#L131-L147

it prints:

map[string]interface {}{}

while the previous test prints the following, which is what I want:

map[string]interface {}{"Servers":[]main.Server{main.Server{Name:"Arslan", ID:123456, Enabled:true}, main.Server{Name:"Arslan", ID:123456, Enabled:true}}}

How to fix it to make it working? Thx!

Hi @suntong The servers field need to be uppercase, so Servers. Otherwise the reflect package will not read it. Here is the same example: https://play.golang.org/p/rP5q47J3Ke