Don't blindly SetString.
This commit is contained in:
@@ -368,6 +368,9 @@ func pathMapper(r *Registry) MapperFunc {
|
||||
if target.Kind() == reflect.Slice {
|
||||
return sliceDecoder(r)(ctx, target)
|
||||
}
|
||||
if target.Kind() != reflect.String {
|
||||
return fmt.Errorf("\"path\" type must be applied to a string not %s", target.Type())
|
||||
}
|
||||
path := ctx.Scan.PopValue("file")
|
||||
path = expandPath(path)
|
||||
target.SetString(path)
|
||||
@@ -380,6 +383,9 @@ func existingFileMapper(r *Registry) MapperFunc {
|
||||
if target.Kind() == reflect.Slice {
|
||||
return sliceDecoder(r)(ctx, target)
|
||||
}
|
||||
if target.Kind() != reflect.String {
|
||||
return fmt.Errorf("\"existingfile\" type must be applied to a string not %s", target.Type())
|
||||
}
|
||||
path := ctx.Scan.PopValue("file")
|
||||
path = expandPath(path)
|
||||
stat, err := os.Stat(path)
|
||||
@@ -399,6 +405,9 @@ func existingDirMapper(r *Registry) MapperFunc {
|
||||
if target.Kind() == reflect.Slice {
|
||||
return sliceDecoder(r)(ctx, target)
|
||||
}
|
||||
if target.Kind() != reflect.String {
|
||||
return fmt.Errorf("\"existingdir\" must be applied to a string not %s", target.Type())
|
||||
}
|
||||
path := ctx.Scan.PopValue("file")
|
||||
path = expandPath(path)
|
||||
stat, err := os.Stat(path)
|
||||
|
||||
Reference in New Issue
Block a user