Merge pull request #17 from ceh/fix-format-errors
decoder: fix format error due to invalid argument (byte to string)
This commit is contained in:
commit
96d5b40433
13
decoder.go
13
decoder.go
@ -96,7 +96,7 @@ func (d *decoder) decodeBool(name string, o *hcl.Object, result reflect.Value) e
|
|||||||
case hcl.ValueTypeBool:
|
case hcl.ValueTypeBool:
|
||||||
result.Set(reflect.ValueOf(o.Value.(bool)))
|
result.Set(reflect.ValueOf(o.Value.(bool)))
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("%s: unknown type %s", name, o.Type)
|
return fmt.Errorf("%s: unknown type %v", name, o.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -107,7 +107,7 @@ func (d *decoder) decodeFloat(name string, o *hcl.Object, result reflect.Value)
|
|||||||
case hcl.ValueTypeFloat:
|
case hcl.ValueTypeFloat:
|
||||||
result.Set(reflect.ValueOf(o.Value.(float64)))
|
result.Set(reflect.ValueOf(o.Value.(float64)))
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("%s: unknown type %s", name, o.Type)
|
return fmt.Errorf("%s: unknown type %v", name, o.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -125,7 +125,7 @@ func (d *decoder) decodeInt(name string, o *hcl.Object, result reflect.Value) er
|
|||||||
|
|
||||||
result.SetInt(int64(v))
|
result.SetInt(int64(v))
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("%s: unknown type %s", name, o.Type)
|
return fmt.Errorf("%s: unknown type %v", name, o.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -196,7 +196,7 @@ func (d *decoder) decodeInterface(name string, o *hcl.Object, result reflect.Val
|
|||||||
|
|
||||||
func (d *decoder) decodeMap(name string, o *hcl.Object, result reflect.Value) error {
|
func (d *decoder) decodeMap(name string, o *hcl.Object, result reflect.Value) error {
|
||||||
if o.Type != hcl.ValueTypeObject {
|
if o.Type != hcl.ValueTypeObject {
|
||||||
return fmt.Errorf("%s: not an object type for map (%s)", name, o.Type)
|
return fmt.Errorf("%s: not an object type for map (%v)", name, o.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have an interface, then we can address the interface,
|
// If we have an interface, then we can address the interface,
|
||||||
@ -324,7 +324,7 @@ func (d *decoder) decodeString(name string, o *hcl.Object, result reflect.Value)
|
|||||||
case hcl.ValueTypeString:
|
case hcl.ValueTypeString:
|
||||||
result.Set(reflect.ValueOf(o.Value.(string)).Convert(result.Type()))
|
result.Set(reflect.ValueOf(o.Value.(string)).Convert(result.Type()))
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("%s: unknown type to string: %s", name, o.Type)
|
return fmt.Errorf("%s: unknown type to string: %v", name, o.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -332,8 +332,7 @@ func (d *decoder) decodeString(name string, o *hcl.Object, result reflect.Value)
|
|||||||
|
|
||||||
func (d *decoder) decodeStruct(name string, o *hcl.Object, result reflect.Value) error {
|
func (d *decoder) decodeStruct(name string, o *hcl.Object, result reflect.Value) error {
|
||||||
if o.Type != hcl.ValueTypeObject {
|
if o.Type != hcl.ValueTypeObject {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf("%s: not an object type for struct (%v)", name, o.Type)
|
||||||
"%s: not an object type for struct (%s)", name, o.Type)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This slice will keep track of all the structs we'll be decoding.
|
// This slice will keep track of all the structs we'll be decoding.
|
||||||
|
Loading…
Reference in New Issue
Block a user