Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

fix: special slice types cause panic when reflectively generating values #91

Merged
merged 1 commit into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions faker.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ func getValue(a interface{}) (reflect.Value, error) {
if err != nil {
return reflect.Value{}, err
}
val = val.Convert(v.Index(i).Type())
v.Index(i).Set(val)
}
return v, nil
Expand Down
4 changes: 4 additions & 0 deletions faker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const (
someStructBoundaryEnd = 10
)

type SomeInt32 int32

type SomeStruct struct {
Inta int
Int8 int8
Expand Down Expand Up @@ -61,6 +63,8 @@ type SomeStruct struct {
MapStringString map[string]string
MapStringStruct map[string]AStruct
MapStringStructPointer map[string]*AStruct

SomeInt32s []SomeInt32
}

type SomeStructWithLen struct {
Expand Down