Skip to content

Commit 243da22

Browse files
committed
handle different types in parsed max_length
1 parent be6af55 commit 243da22

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pkg/cmd/io.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,21 @@ func parseInput(stdin io.Reader) *types.Inputs {
4343
}
4444

4545
if maxLength, ok := inputsMap["max_length"]; ok {
46-
inputs.MaxLength = int(maxLength.(float64))
46+
switch maxLength.(type) {
47+
case float64:
48+
inputs.MaxLength = int(maxLength.(float64))
49+
break
50+
case string:
51+
var convError error
52+
inputs.MaxLength, convError = strconv.Atoi(maxLength.(string))
53+
if convError != nil {
54+
log.Fatalf("Error unmarshaling inputs.max_length; %v", convError)
55+
}
56+
break
57+
case int64:
58+
inputs.MaxLength = int(maxLength.(int64))
59+
break
60+
}
4761
}
4862
}
4963
return &inputs

0 commit comments

Comments
 (0)