Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Use "." to refer to the current path's package in reflect mode #387

Merged
merged 3 commits into from
Feb 2, 2020

Conversation

XSAM
Copy link
Contributor

@XSAM XSAM commented Jan 18, 2020

Description

I use go:generate in my source code to invoke mockgen to generate mocked interfaces.

e.g.

//go:generate mockgen -destination=mocks/foo.pb.go github.com/xxx/xxx/pkg/xxx Foo

But it's too annoying that every time I have to write and check the package name (github.com/xxx/xxx/pkg/xxx).

And add the full package name in a source file is kind of duplicated information since golang could parse the file path and get the package name.

So I add a feature that can use "." to refer to the current path's package.

e.g.

//go:generate mockgen -destination=mocks/foo.pb.go . Foo

Just a single ., no more github.com/xxx/xxx/pkg/xxx.

Release Notes

Use "." to refer to the current path's package in reflect mode

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@XSAM
Copy link
Contributor Author

XSAM commented Jan 18, 2020

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@codyoss
Copy link
Member

codyoss commented Jan 20, 2020

Hey @XSAM, thanks for the PR. Is their a corresponding issue that goes with this PR? If not, could you please create one to discuss the feature.

@XSAM
Copy link
Contributor Author

XSAM commented Jan 20, 2020

I created an issue. #388

@cvgw cvgw self-requested a review January 24, 2020 18:26
@cvgw cvgw self-assigned this Jan 24, 2020
@cvgw
Copy link
Collaborator

cvgw commented Jan 31, 2020

@XSAM can we update this block

g.p("// Code generated by MockGen. DO NOT EDIT.")
so that the generated code has // Source: {PKG_NAME} instead of // Source: .

@XSAM
Copy link
Contributor Author

XSAM commented Feb 1, 2020

@cvgw sure, now it generates // Source: {PKG_NAME} while using . as package name.

@cvgw cvgw merged commit 5c85495 into golang:master Feb 2, 2020
@cvgw
Copy link
Collaborator

cvgw commented Feb 2, 2020

@XSAM thank you for the contribution 🎉

@XSAM XSAM deleted the feature/dot-package-name branch February 3, 2020 01:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants