diff --git a/mapper.go b/mapper.go index 96e0185..322ab46 100644 --- a/mapper.go +++ b/mapper.go @@ -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)