Skip to content

Conversation

@ag9920
Copy link

@ag9920 ag9920 commented Mar 8, 2022

This PR tries to fix a variable shadowing problem and format the copier_test.go file.

The copier function declares a returned variable err, which saves the trouble of initializing inside the body.

func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)

But then the err variable would be shadowed by the returned error of getFlags function ( line 235), which makes it impossible to return the error message from checkBitFlags(flgs.BitFlags) function call (line 370).

From a caller's perspective, even if a "must,nopanic" tag was set, no error will be returned. This PR would fix the problem and provide the corresponding test case in copier_tags_test.go (TestCopyTagMustNoPanic).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant