convert types for type aliases
This commit is contained in:
parent
437eb0d851
commit
0b07544203
@ -323,9 +323,9 @@ func (d *decoder) decodeString(name string, raw ast.Node, result reflect.Value)
|
||||
switch n.Type {
|
||||
case ast.ValueTypeInt:
|
||||
result.Set(reflect.ValueOf(
|
||||
strconv.FormatInt(int64(n.Value.(int)), 10)))
|
||||
strconv.FormatInt(int64(n.Value.(int)), 10)).Convert(result.Type()))
|
||||
case ast.ValueTypeString:
|
||||
result.Set(reflect.ValueOf(n.Value.(string)))
|
||||
result.Set(reflect.ValueOf(n.Value.(string)).Convert(result.Type()))
|
||||
default:
|
||||
return fmt.Errorf("%s: unknown type to string: %s", name, n.Type)
|
||||
}
|
||||
|
@ -188,9 +188,11 @@ func TestDecode_structureArray(t *testing.T) {
|
||||
// This test is extracted from a failure in Consul (consul.io),
|
||||
// hence the interesting structure naming.
|
||||
|
||||
type KeyPolicyType string
|
||||
|
||||
type KeyPolicy struct {
|
||||
Prefix string `hcl:",key"`
|
||||
Policy string
|
||||
Policy KeyPolicyType
|
||||
}
|
||||
|
||||
type Policy struct {
|
||||
|
Loading…
Reference in New Issue
Block a user