Skip to content

Commit cdd78af

Browse files
author
Mike Farah
committed
Fixed bug #11: Inability to set field to empty string
1 parent d07e436 commit cdd78af

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

yaml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func updateYaml(args []string) interface{} {
195195

196196
func parseValue(argument string) interface{} {
197197
var value, err interface{}
198-
var inQuotes = argument[0] == '"'
198+
var inQuotes = len(argument) > 0 && argument[0] == '"'
199199
if !inQuotes {
200200
value, err = strconv.ParseFloat(argument, 64)
201201
if err == nil {

yaml_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var parseValueTests = []struct {
1414
{"\"true\"", "true", "boolean as string"},
1515
{"3.4", 3.4, "number"},
1616
{"\"3.4\"", "3.4", "number as string"},
17+
{"", "", "empty string"},
1718
}
1819

1920
func TestParseValue(t *testing.T) {

0 commit comments

Comments
 (0)