Fixed bug #11: Inability to set field to empty string

This commit is contained in:
Mike Farah 2017-06-06 10:19:32 +10:00
parent d07e436065
commit cdd78af4bc
2 changed files with 2 additions and 1 deletions

View File

@ -195,7 +195,7 @@ func updateYaml(args []string) interface{} {
func parseValue(argument string) interface{} {
var value, err interface{}
var inQuotes = argument[0] == '"'
var inQuotes = len(argument) > 0 && argument[0] == '"'
if !inQuotes {
value, err = strconv.ParseFloat(argument, 64)
if err == nil {

View File

@ -14,6 +14,7 @@ var parseValueTests = []struct {
{"\"true\"", "true", "boolean as string"},
{"3.4", 3.4, "number"},
{"\"3.4\"", "3.4", "number as string"},
{"", "", "empty string"},
}
func TestParseValue(t *testing.T) {