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

feat: support get private member method #36

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

smallchimney
Copy link

What type of PR is this?

feat: A new feature

What this PR does / why we need it (en: English/zh: Chinese):

en: 1. We need to mock some method even if it's not exported, like (*sha256.digest).checksum or other method; 2. We need some helper function to migrate gomonkey.ApplyPrivateMethod.
zh: 1. 某些场景下我们需要Mock私有方法,比如(*sha256.digest).checksum;2. 我们需要一个辅助函数去实现从gomonkey.ApplyPrivateMethod的代码实现迁移。

@smallchimney
Copy link
Author

Is there any possible to upgrade GetPrivateMethod to generic function in place?

@smallchimney
Copy link
Author

I've tryed to resolve function type from reflect information, but saddly the type info of private methods have not been written for reflect package

@smallchimney
Copy link
Author

btw, the branch develop described in CONTRIBUTION.md is not exist yet.

@smallchimney
Copy link
Author

add the missing license decriptions

utils.go Outdated Show resolved Hide resolved
@ycydsxy
Copy link
Collaborator

ycydsxy commented Sep 20, 2023

Good job. But some tests failed ...

@Sychorius
Copy link
Collaborator

Sychorius commented Sep 20, 2023

Try put generics-required code into another .go file with compile option like this:

//go:build go1.18
// +build go1.18

@smallchimney
Copy link
Author

The CI testing is failed with Go1.13, which reflect.Pointer has not been declared, I changed to use reflect.Ptr for the compatibility

@ycydsxy
Copy link
Collaborator

ycydsxy commented Oct 11, 2023

some tests still failed

@smallchimney smallchimney force-pushed the feat/get_private_method branch 2 times, most recently from 8ee9996 to 2ce8577 Compare October 11, 2023 10:44
@smallchimney
Copy link
Author

fixed, I've tried go1.13, 1.16, 1.17, 1.18, 1.19 and 1.20 on my dev env.

@smallchimney smallchimney force-pushed the feat/get_private_method branch 2 times, most recently from 4519bcf to eea6667 Compare October 11, 2023 10:56
@ycydsxy ycydsxy merged commit 544448c into bytedance:main Oct 17, 2023
10 of 12 checks passed
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.

3 participants