Skip to content

When a struct has a map field flatpack skips the rest of the fields #4

Description

@arangamani

In the following example

package main

import (
    "fmt"

    "github.com/xeger/flatpack"
)

type Config struct {
    Database struct {
        Host []string `flatpack:"required"`
        Port int
    }
    Awesome struct {
        NotNeeded    map[string]string
        Needed       int
        ReallyNeeded string
    }

    WidgetFactory string
}

func main() {
    var config = Config{}
    err := flatpack.Unmarshal(&config)
    if err != nil {
        fmt.Printf("Failed to load configuration: %v\n", err.Error())
    }
    fmt.Println(config)
}

Running

DATABASE_HOST=[\"foo\"] AWESOME_NEEDED=10 go run main.go

doesn't populate the Needed field. But if I remove the NotNeeded map field, it works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions