Skip to content

Commit 2442d95

Browse files
committed
use an interface{} instead of reflect.Value
1 parent b1a42b8 commit 2442d95

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

group.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ func (g *Group) AddGroup(shortDescription string, longDescription string, data i
7474
}
7575

7676
// AddOption adds a new option to this group.
77-
func (g *Group) AddOption(option *Option, value reflect.Value) {
78-
option.value = value
77+
func (g *Group) AddOption(option *Option, data interface{}) {
78+
option.value = reflect.ValueOf(data)
7979
option.group = g
8080
g.options = append(g.options, option)
8181
}

group_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package flags
22

33
import (
4-
"reflect"
54
"testing"
65
)
76

@@ -262,7 +261,7 @@ func TestAddOptionNonOptional(t *testing.T) {
262261
p := NewParser(&opts, Default)
263262
p.AddOption(&Option{
264263
LongName: "test",
265-
}, reflect.ValueOf(&opts.Test))
264+
}, &opts.Test)
266265
_, err := p.ParseArgs([]string{"--test"})
267266
if err != nil {
268267
t.Errorf("unexpected error: %s", err)

0 commit comments

Comments
 (0)