Skip to content

Commit a031015

Browse files
committed
fixed boolean options parsing
1 parent 7f0e06f commit a031015

File tree

1 file changed

+12
-30
lines changed

1 file changed

+12
-30
lines changed

main.go

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,52 +62,34 @@ func (o *optionsStruct) Unmarshal(options map[string]interface{}) {
6262
}
6363
}
6464

65-
connectInterface, ok := options["connect"]
65+
_, ok = options["connect"]
6666
if ok {
67-
connect, ok := connectInterface.(bool)
68-
if ok {
69-
o.Connect = connect
70-
}
67+
o.Connect = true
7168
}
7269

73-
tableExistsInterface, ok := options["table_exists"]
70+
_, ok = options["table_exists"]
7471
if ok {
75-
tableExists, ok := tableExistsInterface.(bool)
76-
if ok {
77-
o.TableExists = tableExists
78-
}
72+
o.TableExists = true
7973
}
8074

81-
rowExistsInterface, ok := options["row_exists"]
75+
_, ok = options["row_exists"]
8276
if ok {
83-
rowExists, ok := rowExistsInterface.(bool)
84-
if ok {
85-
o.RowExists = rowExists
86-
}
77+
o.RowExists = true
8778
}
8879

89-
regexMatchInterface, ok := options["regex_match"]
80+
_, ok = options["regex_match"]
9081
if ok {
91-
regexMatch, ok := regexMatchInterface.(bool)
92-
if ok {
93-
o.RegexMatch = regexMatch
94-
}
82+
o.RegexMatch = true
9583
}
9684

97-
substringMatchInterface, ok := options["substring_match"]
85+
_, ok = options["substring_match"]
9886
if ok {
99-
substringMatch, ok := substringMatchInterface.(bool)
100-
if ok {
101-
o.SubstringMatch = substringMatch
102-
}
87+
o.SubstringMatch = true
10388
}
10489

105-
matchInterface, ok := options["match"]
90+
_, ok = options["match"]
10691
if ok {
107-
match, ok := matchInterface.(bool)
108-
if ok {
109-
o.Match = match
110-
}
92+
o.Match = true
11193
}
11294
}
11395

0 commit comments

Comments
 (0)