Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent reinitialize error at getFlags #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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