Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
B
bunqapi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sybren A. Stüvel
bunqapi
Commits
76786482
Commit
76786482
authored
May 25, 2019
by
Sybren A. Stüvel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MergeStructs: panic when unexpected property kind is found
parent
37960dc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
merge_structs.go
merge_structs.go
+5
-4
No files found.
merge_structs.go
View file @
76786482
...
...
@@ -53,7 +53,6 @@ func MergeStructs(responses interface{}, mergedResp interface{}) {
responseValue
:=
responsesValue
.
Index
(
index
)
for
fieldnum
:=
0
;
fieldnum
<
numFields
;
fieldnum
++
{
// field := respType.Field(fieldnum)
fieldVal
:=
responseValue
.
Field
(
fieldnum
)
// Skip unexported fields.
...
...
@@ -61,7 +60,7 @@ func MergeStructs(responses interface{}, mergedResp interface{}) {
continue
}
// fmt.Printf(" - field %d: %10v ", fieldnum,
field
.Name)
// fmt.Printf(" - field %d: %10v ", fieldnum,
respType.Field(fieldnum)
.Name)
useValue
:=
false
switch
fieldVal
.
Kind
()
{
case
reflect
.
Ptr
:
...
...
@@ -73,8 +72,11 @@ func MergeStructs(responses interface{}, mergedResp interface{}) {
case
reflect
.
Bool
:
useValue
=
fieldVal
.
Bool
()
// fmt.Printf("is bool : %v", useValue)
case
reflect
.
Int
:
useValue
=
fieldVal
.
Int
()
!=
0
// fmt.Printf("is int : %v", useValue)
default
:
// fmt.Printf("is kind : %v (not using)", fieldVal.Kind(
))
panic
(
fmt
.
Sprintf
(
"field %s is of unmergeable kind %v"
,
respType
.
Field
(
fieldnum
)
.
Name
,
fieldVal
.
Kind
()
))
}
// fmt.Println()
...
...
@@ -84,7 +86,6 @@ func MergeStructs(responses interface{}, mergedResp interface{}) {
resultField
:=
resultValue
.
Field
(
fieldnum
)
resultField
.
Set
(
fieldVal
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment