-
Notifications
You must be signed in to change notification settings - Fork 106
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
Replace 'interface{}' with 'any' #48
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
By running the command: gofmt -w -r 'interface{} -> any' .
r-hang
approved these changes
Aug 1, 2023
JacobOaks
approved these changes
Aug 1, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
sywhang
approved these changes
Aug 3, 2023
r-hang
added a commit
that referenced
this pull request
Sep 5, 2023
Running `go generate ./...` on current main fails for a couple of reasons (1) The go:generate command in /mockgen/internal/tests/aux_imports_embedded_interface/bugreport.go has an -aux_file argument that specifies a package `faux` that is not in the stdlib and therefore not discoverable in GOROOT. Fixing this with a fully qualified path causes another failure that is known and documented in mockgen/internal/tests/aux_imports_embedded_interface/README.md. Because this failure is known, I've opted to comment out the command as documentation for reproducing the error. (2) mockgen/internal/tests/internal_pkg/generate.go attempts to mock an interface package with reflect mode and runs into fundamental go restrictions of `go build` with internal package paths outside of the internal package scope allowed by go. I've removed the generate directive here since this isn't a supported feature as the implementation of reflect mode creates a tempoorary directory and invokes `go build` there. ref: github.com/uber-go/mock/blob/8cd1a4cf46a6b1cf232b6862f2f11e81fe77a4e4/mockgen/reflect.go#L135 ref: github.com/golang/mock/issues/29 Not a failure fix but I've also changed type aliases of `any` back to type aliases of `interface {}`. Looking at the parsing logic, github.com/uber-go/mock/blob/8cd1a4cf46a6b1cf232b6862f2f11e81fe77a4e4/mockgen/parse.go#L752 `interface{}` -> `any` causes *ast.TypeSpec to no longer type check to an *ast.InterfaceType and ends up removing generate mock code meant to test against regressions. ref: github.com//pull/48
r-hang
added a commit
that referenced
this pull request
Sep 5, 2023
Running `go generate ./...` on current main fails for a couple of reasons (1) The go:generate command in /mockgen/internal/tests/aux_imports_embedded_interface/bugreport.go has an -aux_file argument that specifies a package `faux` that is not in the stdlib and therefore not discoverable in GOROOT. Fixing this with a fully qualified path causes another failure that is known and documented in mockgen/internal/tests/aux_imports_embedded_interface/README.md. Because this failure is known, I've opted to comment out the command as documentation for reproducing the error. (2) mockgen/internal/tests/internal_pkg/generate.go attempts to mock an interface package with reflect mode and runs into fundamental go restrictions of `go build` with internal package paths outside of the internal package scope allowed by go. I've removed the generate directive here since this isn't a supported feature as the implementation of reflect mode creates a tempoorary directory and invokes `go build` there. ref: [reflect.go#L135](github.com/uber-go/mock/blob/8cd1a4cf46a6b1cf232b6862f2f11e81fe77a4e4/mockgen/reflect.go#L135) ref: [#29](github.com/golang/mock/issues/29) Not a failure fix but I've also changed type aliases of `any` back to type aliases of `interface {}`. Looking at the parsing logic, [parse.go#L752](github.com/uber-go/mock/blob/8cd1a4cf46a6b1cf232b6862f2f11e81fe77a4e4/mockgen/parse.go#L752) `interface{}` -> `any` causes *ast.TypeSpec to no longer type check to an *ast.InterfaceType and ends up removing generate mock code meant to test against regressions. ref: [#48](github.com//pull/48)
r-hang
pushed a commit
that referenced
this pull request
Jul 10, 2024
I updated the CI to use the two newest stable versions of go (v1.21.x and v1.22.x) to test the code as well as the oldest version (`v1.19.x`) that could still be used to build the source. The behaviour of the `go version` line in `go.mod` changed with `v1.21.x`: it should state the oldest version of go that is needed to build the source. The source builds and tests fine with `v1.19.x`, older versions however fail, so I set it to this version. Before my changes the `test` GH workflow didn't actually execute `./ci/test.sh` because there is was check that skipped testing if the used go version was any other than `1.18`. I removed this check which showed some tests failing even without my changes. The issue turned out to have been introduced by accident (because tests weren't executed) in #48. The fix for it can be found in commit 0403497 (part of this PR). Additionally I had to regenerate all mocks or `./ci/tests.sh` would complain that they weren't up to date.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces
interface{}
withany
by running the command: