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

Nested array structs dont pick up custom tags

shardnit opened this issue · comments

Consider following example where struct person consists of array of addresses:

package main

import (
    "fmt"

    "github.com/fatih/structs"
)

func main() {
    type address struct {
        Country string `structs:"country"`
    }

    type person struct {
        Name      string    `structs:"name"`
        Addresses []address `structs:"addresses"`
    }

    p := person{Name: "test", Addresses: []address{address{Country: "England"}}}
    fmt.Printf("%+v", structs.Map(p))
}

The output is (custom tag for country is not picked):
map[name:test addresses:[{Country:England}]]

while the expected output is:
map[name:test addresses:[{country:England}]]

Thanks @shardnit

I'll take a look soon at it. My macbook was broken and I didn't had the time to look at it.

I think that the correct output should be
map[name:test addresses:[map[country:England]]]

@shardnit checkout please #60, it solves your problem.