Skip to content

Strange behavior when working with pointer field #26

Open
@zhaoyao

Description

@zhaoyao

Test code

package main

import "github.com/koding/multiconfig"
import "os"
import "time"

type duration struct {
    time.Duration
}

func (d *duration) UnmarshalText(text []byte) error {
    var err error
    d.Duration, err = time.ParseDuration(string(text))
    return err
}

type A struct {
    //B *duration `default:"10s"`

    // works as expected
    B *duration `toml:"b"`
}

func main() {
    a := &A{}
    multiconfig.MustLoadWithPath(os.Args[1], a)
    println(a.B.String())
}

When specify argument value through env or cli args for pointer type, will cause multiconfig compain "not support type: ptr"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions