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 {
|
switch n.Type {
|
||||||
case ast.ValueTypeInt:
|
case ast.ValueTypeInt:
|
||||||
result.Set(reflect.ValueOf(
|
result.Set(reflect.ValueOf(
|
||||||
strconv.FormatInt(int64(n.Value.(int)), 10)))
|
strconv.FormatInt(int64(n.Value.(int)), 10)).Convert(result.Type()))
|
||||||
case ast.ValueTypeString:
|
case ast.ValueTypeString:
|
||||||
result.Set(reflect.ValueOf(n.Value.(string)))
|
result.Set(reflect.ValueOf(n.Value.(string)).Convert(result.Type()))
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("%s: unknown type to string: %s", name, n.Type)
|
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),
|
// This test is extracted from a failure in Consul (consul.io),
|
||||||
// hence the interesting structure naming.
|
// hence the interesting structure naming.
|
||||||
|
|
||||||
|
type KeyPolicyType string
|
||||||
|
|
||||||
type KeyPolicy struct {
|
type KeyPolicy struct {
|
||||||
Prefix string `hcl:",key"`
|
Prefix string `hcl:",key"`
|
||||||
Policy string
|
Policy KeyPolicyType
|
||||||
}
|
}
|
||||||
|
|
||||||
type Policy struct {
|
type Policy struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user