Skip to content

Conversation

bstncartwright
Copy link
Contributor

Resolves #218

This is my first time contributing to this project, please let me know if there is anything I need to change. Thanks!

@HassanCehef
Copy link

I'm not a maintainer; I reported the bug.

I like the fix. Name collisions have always been possible: they didn't happen so much because "arg0"..."arg5" are not usual package names.
How about using this as a suffix rather than a full replacement?
DoThat(internalpackage int): instead of becoming

-func (m *MockMything) DoThat(arg0 int) internalpackage.FooExported {
+func (m *MockMything) DoThat(internalpackage_arg0 int) internalpackage.FooExported {

this way we still get the v0.5.0 feature that provides human readable names when using mocks in all cases.

@bstncartwright
Copy link
Contributor Author

I'm not a maintainer; I reported the bug.

I like the fix. Name collisions have always been possible: they didn't happen so much because "arg0"..."arg5" are not usual package names. How about using this as a suffix rather than a full replacement? DoThat(internalpackage int): instead of becoming

-func (m *MockMything) DoThat(arg0 int) internalpackage.FooExported {
+func (m *MockMything) DoThat(internalpackage_arg0 int) internalpackage.FooExported {

this way we still get the v0.5.0 feature that provides human readable names when using mocks in all cases.

Interesting, I like that idea but I wonder if it could cause more confusion. Auto-complete from the LSP could show internalpackage_arg0 and the developer might think it is an argument of that package? Just a thought, I am open to finding the best answer here!

Copy link
Contributor

@tchung1118 tchung1118 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment. Also, could you re-generate existing test mocks?

@bstncartwright bstncartwright force-pushed the fix/arg-package-conflict branch from 1a87bd5 to 92587e1 Compare October 28, 2024 15:25
@bstncartwright
Copy link
Contributor Author

Added a comment. Also, could you re-generate existing test mocks?

Done. Thanks for your review!

Copy link
Contributor

@tchung1118 tchung1118 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for your contribution!

@tchung1118 tchung1118 merged commit eb67641 into uber-go:main Oct 28, 2024
3 checks passed
@bstncartwright bstncartwright deleted the fix/arg-package-conflict branch October 28, 2024 19:10
@becoded
Copy link

becoded commented Nov 15, 2024

@tchung1118 can we expect a new patch/minor release for this fix anytime soon?

@arxeiss
Copy link

arxeiss commented Apr 3, 2025

Hello, is Mock package still maintained? We are still using v0.4.0, this issue is obviously solved. But without new release it is just half way done.

@coderabbitai coderabbitai bot mentioned this pull request Apr 7, 2025
apricote pushed a commit to hetznercloud/fleeting-plugin-hetzner that referenced this pull request Apr 8, 2025
…eting-plugin-hetzner!238)

This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [go.uber.org/mock](https://github.com/uber/mock) | require | patch | `v0.5.0` -> `v0.5.1` |

---

### Release Notes

<details>
<summary>uber/mock (go.uber.org/mock)</summary>

### [`v0.5.1`](https://github.com/uber-go/mock/releases/tag/v0.5.1)

[Compare Source](uber-go/mock@v0.5.0...v0.5.1)

#### 0.5.1 (7 Apr 2025)

##### Fixed

-   [#&#8203;220][]: Package mode will now generate code that uses aliases of types
    when they are used in the source.
-   [#&#8203;219][]: Fixed a collision between function argument names and package names
    in generated code.
-   [#&#8203;165][]: Fixed an issue where aliases specified by `-imports` were not being
    respected in generated code.

[#&#8203;220]: uber-go/mock#220

[#&#8203;219]: uber-go/mock#219

[#&#8203;165]: uber-go/mock#165

Thanks to [@&#8203;mtoader](https://github.com/mtoader) and [@&#8203;bstncartwright](https://github.com/bstncartwright) for their contributions to this release.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMzUuMiIsInVwZGF0ZWRJblZlciI6IjM5LjIzNS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
DennisRasey pushed a commit to DennisRasey/forgejo that referenced this pull request Apr 8, 2025
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [go.uber.org/mock](https://github.com/uber/mock) | require | patch | `v0.5.0` -> `v0.5.1` |

---

### Release Notes

<details>
<summary>uber/mock (go.uber.org/mock)</summary>

### [`v0.5.1`](https://github.com/uber-go/mock/releases/tag/v0.5.1)

[Compare Source](uber-go/mock@v0.5.0...v0.5.1)

#### 0.5.1 (7 Apr 2025)

##### Fixed

-   [#&#8203;220][]: Package mode will now generate code that uses aliases of types
    when they are used in the source.
-   [#&#8203;219][]: Fixed a collision between function argument names and package names
    in generated code.
-   [#&#8203;165][]: Fixed an issue where aliases specified by `-imports` were not being
    respected in generated code.

[#&#8203;220]: uber-go/mock#220

[#&#8203;219]: uber-go/mock#219

[#&#8203;165]: uber-go/mock#165

Thanks to [@&#8203;mtoader](https://github.com/mtoader) and [@&#8203;bstncartwright](https://github.com/bstncartwright) for their contributions to this release.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "* 0-3 * * *" (UTC), Automerge - "* 0-3 * * *" (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMzMuNSIsInVwZGF0ZWRJblZlciI6IjM5LjIzMy41IiwidGFyZ2V0QnJhbmNoIjoiZm9yZ2VqbyIsImxhYmVscyI6WyJkZXBlbmRlbmN5LXVwZ3JhZGUiLCJ0ZXN0L25vdC1uZWVkZWQiXX0=-->

Co-authored-by: Gusted <[email protected]>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7488
Reviewed-by: Earl Warren <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
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.

v0.5.0 mock generated do not compile due to name clash
5 participants