-
Notifications
You must be signed in to change notification settings - Fork 114
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
Improve package-sniffing and bind correctly to types in the same package #316
Conversation
The original motivation here is to fix #283, which is that if you try to use `bindings` to bind to a type in the same package as the generated code, we generate a self-import, which Go doesn't allow. Fixing that is easy -- the three lines in `imports.go` -- once you know the package-path of the generated code. (The test that that all fits together is in integration-tests because that was the easiest place to set up the right situation.) Determining the package-path is not too much harder: you ask `go/packages`, which we already use for `package_bindings`. But once we're doing that, and handling errors, it's kinda silly that we ask you to specify the package your generated code will use, because we have that too, usually. So I rewrote that handling too, making `package` now rarely necessary (see for example the `example` config), and warning if it looks wrong. This is the changes in `config.go`, and is the more substantial non-test change. (I also renamed some of the testdata dirs to be valid package-names, to exercise more of that code, or in the case of `find-config`, just for consistency.)
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.
This looks good to me! I like figuring out the package name automatically; that makes a lot of sense to me. Some style comments below but nothing requiring another go-around.
pkgNameGuess := filepath.Base(dir) | ||
if !token.IsIdentifier(pkgNameGuess) { | ||
pkgNameGuess = "" | ||
} |
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.
It seems like this could profitably be later down in the function, maybe lines 166- could be something like:
packageNameGuess := ""
if token.IsIdentifier(filepath.Base(pkg.PkgPath)) {
pkgNameGuess = filepath.Base(pkg.PkgPath)
} else if token.IsIdentifier(filepath.Base(dir)) {
pkgNameGuess = filepath.Base(dir)
}
But I don't really understand if/how that else
case could fire. Maybe add some documentation here.
generate/config.go
Outdated
// TODO(benkraft): Can PkgPath ever be empty without error? If so, we could | ||
// warn. |
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.
Yeah, I don't know the semantics of packages.Load, but it seems like Name is empty if the package doesn't exist, but PkgPath is still set in that case?
generate/config.go
Outdated
return pkg.Name, pkg.PkgPath, nil | ||
} | ||
|
||
// e.g. empty package yet to be created, see if we can just guess a |
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, this comment is very helpful!
generate/config.go
Outdated
"\nSet package name in genqlient.yaml"+ | ||
"\nExample: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L6", base) | ||
pkgName, pkgPath, err := c.getPackageNameAndPath() | ||
if err == nil { |
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.
It took me a while to figure out what was going on here, because I'm so used to the Go convention of checking for the error case in the if's, not the success case.
I wonder if there's a way to reorganize this code to keep the current semantics but perhaps adhere more closely to Go convention. Maybe not.
generate/config.go
Outdated
// binding against the generated package, so at least warn. | ||
warn(errorf(nil, "warning: unable to identify current package-path "+ | ||
"(using 'package' config '%v'): %v\n", c.Package, err)) | ||
} else if pkgName != "" { |
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.
It's unusual, though I guess not unheard of, for the value of the other return-values to matter when err
is not nil. It may be worth emphasizing this in the relevant parts of getPackageNameAndPath, though.
generate/config.go
Outdated
return errorf(nil, "unable to guess package-name: '%v' is not a valid identifier"+ | ||
"\nSet package name in genqlient.yaml"+ | ||
"\nExample: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L6", base) | ||
pkgName, pkgPath, err := c.getPackageNameAndPath() |
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.
You may want to comment that this ignores c.Package, and that below you'll check to make sure they're in agreement (or, at least, not in disagreement.)
generate/config.go
Outdated
@@ -201,6 +256,11 @@ func (c *Config) ValidateAndFillDefaults(baseDir string) error { | |||
binding.Package) | |||
} | |||
|
|||
if binding.Package == c.pkgPath { | |||
warn(errorf(nil, "warning: package_bindings set to the same package as your generated "+ | |||
"code ('%v'); this will probably cause circularity issues", c.pkgPath)) |
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.
"probably cause circular-import issues"?
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/Khan/genqlient](https://togithub.com/Khan/genqlient) | `v0.6.0` -> `v0.7.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fKhan%2fgenqlient/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fKhan%2fgenqlient/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fKhan%2fgenqlient/v0.6.0/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fKhan%2fgenqlient/v0.6.0/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>Khan/genqlient (github.com/Khan/genqlient)</summary> ### [`v0.7.0`](https://togithub.com/Khan/genqlient/releases/tag/v0.7.0) [Compare Source](https://togithub.com/Khan/genqlient/compare/v0.6.0...v0.7.0) In addition to several new features and bugfixes, along with this release comes reorganized [documentation](https://togithub.com/Khan/genqlient/blob/main/docs) for genqlient. Note that genqlient now requires Go 1.20 or higher, and is tested through Go 1.22. #### What's Changed - Add "generic" option to the "optional" configuration for handling nullable types by [@​DylanRJohnston](https://togithub.com/DylanRJohnston) in [https://github.com/Khan/genqlient/pull/252](https://togithub.com/Khan/genqlient/pull/252) - Documentation tweaks relating to releases by [@​benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/271](https://togithub.com/Khan/genqlient/pull/271) - Add some better tests for use_struct_references by [@​benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/273](https://togithub.com/Khan/genqlient/pull/273) - Add an option to handle enums with ugly casing by [@​benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/270](https://togithub.com/Khan/genqlient/pull/270) - Add some more tests for config validation, and fix some gaps by [@​benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/274](https://togithub.com/Khan/genqlient/pull/274) - Add consideration for pointer false directive when optional: pointer configuration option is used by [@​spencermurray](https://togithub.com/spencermurray) in [https://github.com/Khan/genqlient/pull/280](https://togithub.com/Khan/genqlient/pull/280) - Update gqlparser and gqlgen dependencies by [@​StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/282](https://togithub.com/Khan/genqlient/pull/282) - Update gqlparser to omit comments by [@​StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/284](https://togithub.com/Khan/genqlient/pull/284) - bugfix: local variable 'data' colliding with argument name by [@​zholti](https://togithub.com/zholti) in [https://github.com/Khan/genqlient/pull/291](https://togithub.com/Khan/genqlient/pull/291) - Pin lint workflow's Go version by [@​benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/311](https://togithub.com/Khan/genqlient/pull/311) - Upgrade golangci-lint and which go we run it with by [@​benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/314](https://togithub.com/Khan/genqlient/pull/314) - fix implementation type generation for fragment on a union by [@​zzh8829](https://togithub.com/zzh8829) in [https://github.com/Khan/genqlient/pull/310](https://togithub.com/Khan/genqlient/pull/310) - Support more valid graphql file extensions by [@​zzh8829](https://togithub.com/zzh8829) in [https://github.com/Khan/genqlient/pull/309](https://togithub.com/Khan/genqlient/pull/309) - Add tests on Go 1.22, and upgrade x/tools to make them work by [@​benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/315](https://togithub.com/Khan/genqlient/pull/315) - Update gqlgen to latest by [@​StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/317](https://togithub.com/Khan/genqlient/pull/317) - move genqlient Go module to 1.20 by [@​StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/318](https://togithub.com/Khan/genqlient/pull/318) - Improve package-sniffing and bind correctly to types in the same package by [@​benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/316](https://togithub.com/Khan/genqlient/pull/316) - Reorganize and improve documentation by [@​benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/322](https://togithub.com/Khan/genqlient/pull/322) - Fix non-deterministic generated code involving interfaces and fragments. by [@​csilvers](https://togithub.com/csilvers) in [https://github.com/Khan/genqlient/pull/323](https://togithub.com/Khan/genqlient/pull/323) - Release v0.7.0 by [@​benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/324](https://togithub.com/Khan/genqlient/pull/324) #### New Contributors - [@​DylanRJohnston](https://togithub.com/DylanRJohnston) made their first contribution in [https://github.com/Khan/genqlient/pull/252](https://togithub.com/Khan/genqlient/pull/252) - [@​spencermurray](https://togithub.com/spencermurray) made their first contribution in [https://github.com/Khan/genqlient/pull/280](https://togithub.com/Khan/genqlient/pull/280) - [@​zholti](https://togithub.com/zholti) made their first contribution in [https://github.com/Khan/genqlient/pull/291](https://togithub.com/Khan/genqlient/pull/291) - [@​zzh8829](https://togithub.com/zzh8829) made their first contribution in [https://github.com/Khan/genqlient/pull/310](https://togithub.com/Khan/genqlient/pull/310) **Full Changelog**: Khan/genqlient@v0.6.0...v0.7.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **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 [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMjAuMiIsInVwZGF0ZWRJblZlciI6IjM3LjIyMC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: opentelemetrybot <[email protected]> Co-authored-by: Andrzej Stencel <[email protected]>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/Khan/genqlient](https://togithub.com/Khan/genqlient) | `v0.6.0` -> `v0.7.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fKhan%2fgenqlient/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fKhan%2fgenqlient/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fKhan%2fgenqlient/v0.6.0/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fKhan%2fgenqlient/v0.6.0/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>Khan/genqlient (github.com/Khan/genqlient)</summary> ### [`v0.7.0`](https://togithub.com/Khan/genqlient/releases/tag/v0.7.0) [Compare Source](https://togithub.com/Khan/genqlient/compare/v0.6.0...v0.7.0) In addition to several new features and bugfixes, along with this release comes reorganized [documentation](https://togithub.com/Khan/genqlient/blob/main/docs) for genqlient. Note that genqlient now requires Go 1.20 or higher, and is tested through Go 1.22. #### What's Changed - Add "generic" option to the "optional" configuration for handling nullable types by [@&open-telemetry#8203;DylanRJohnston](https://togithub.com/DylanRJohnston) in [https://github.com/Khan/genqlient/pull/252](https://togithub.com/Khan/genqlient/pull/252) - Documentation tweaks relating to releases by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/271](https://togithub.com/Khan/genqlient/pull/271) - Add some better tests for use_struct_references by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/273](https://togithub.com/Khan/genqlient/pull/273) - Add an option to handle enums with ugly casing by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/270](https://togithub.com/Khan/genqlient/pull/270) - Add some more tests for config validation, and fix some gaps by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/274](https://togithub.com/Khan/genqlient/pull/274) - Add consideration for pointer false directive when optional: pointer configuration option is used by [@&open-telemetry#8203;spencermurray](https://togithub.com/spencermurray) in [https://github.com/Khan/genqlient/pull/280](https://togithub.com/Khan/genqlient/pull/280) - Update gqlparser and gqlgen dependencies by [@&open-telemetry#8203;StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/282](https://togithub.com/Khan/genqlient/pull/282) - Update gqlparser to omit comments by [@&open-telemetry#8203;StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/284](https://togithub.com/Khan/genqlient/pull/284) - bugfix: local variable 'data' colliding with argument name by [@&open-telemetry#8203;zholti](https://togithub.com/zholti) in [https://github.com/Khan/genqlient/pull/291](https://togithub.com/Khan/genqlient/pull/291) - Pin lint workflow's Go version by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/311](https://togithub.com/Khan/genqlient/pull/311) - Upgrade golangci-lint and which go we run it with by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/314](https://togithub.com/Khan/genqlient/pull/314) - fix implementation type generation for fragment on a union by [@&open-telemetry#8203;zzh8829](https://togithub.com/zzh8829) in [https://github.com/Khan/genqlient/pull/310](https://togithub.com/Khan/genqlient/pull/310) - Support more valid graphql file extensions by [@&open-telemetry#8203;zzh8829](https://togithub.com/zzh8829) in [https://github.com/Khan/genqlient/pull/309](https://togithub.com/Khan/genqlient/pull/309) - Add tests on Go 1.22, and upgrade x/tools to make them work by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/315](https://togithub.com/Khan/genqlient/pull/315) - Update gqlgen to latest by [@&open-telemetry#8203;StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/317](https://togithub.com/Khan/genqlient/pull/317) - move genqlient Go module to 1.20 by [@&open-telemetry#8203;StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/318](https://togithub.com/Khan/genqlient/pull/318) - Improve package-sniffing and bind correctly to types in the same package by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/316](https://togithub.com/Khan/genqlient/pull/316) - Reorganize and improve documentation by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/322](https://togithub.com/Khan/genqlient/pull/322) - Fix non-deterministic generated code involving interfaces and fragments. by [@&open-telemetry#8203;csilvers](https://togithub.com/csilvers) in [https://github.com/Khan/genqlient/pull/323](https://togithub.com/Khan/genqlient/pull/323) - Release v0.7.0 by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/324](https://togithub.com/Khan/genqlient/pull/324) #### New Contributors - [@&open-telemetry#8203;DylanRJohnston](https://togithub.com/DylanRJohnston) made their first contribution in [https://github.com/Khan/genqlient/pull/252](https://togithub.com/Khan/genqlient/pull/252) - [@&open-telemetry#8203;spencermurray](https://togithub.com/spencermurray) made their first contribution in [https://github.com/Khan/genqlient/pull/280](https://togithub.com/Khan/genqlient/pull/280) - [@&open-telemetry#8203;zholti](https://togithub.com/zholti) made their first contribution in [https://github.com/Khan/genqlient/pull/291](https://togithub.com/Khan/genqlient/pull/291) - [@&open-telemetry#8203;zzh8829](https://togithub.com/zzh8829) made their first contribution in [https://github.com/Khan/genqlient/pull/310](https://togithub.com/Khan/genqlient/pull/310) **Full Changelog**: Khan/genqlient@v0.6.0...v0.7.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **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 [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMjAuMiIsInVwZGF0ZWRJblZlciI6IjM3LjIyMC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: opentelemetrybot <[email protected]> Co-authored-by: Andrzej Stencel <[email protected]>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/Khan/genqlient](https://togithub.com/Khan/genqlient) | `v0.6.0` -> `v0.7.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fKhan%2fgenqlient/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fKhan%2fgenqlient/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fKhan%2fgenqlient/v0.6.0/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fKhan%2fgenqlient/v0.6.0/v0.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>Khan/genqlient (github.com/Khan/genqlient)</summary> ### [`v0.7.0`](https://togithub.com/Khan/genqlient/releases/tag/v0.7.0) [Compare Source](https://togithub.com/Khan/genqlient/compare/v0.6.0...v0.7.0) In addition to several new features and bugfixes, along with this release comes reorganized [documentation](https://togithub.com/Khan/genqlient/blob/main/docs) for genqlient. Note that genqlient now requires Go 1.20 or higher, and is tested through Go 1.22. #### What's Changed - Add "generic" option to the "optional" configuration for handling nullable types by [@&open-telemetry#8203;DylanRJohnston](https://togithub.com/DylanRJohnston) in [https://github.com/Khan/genqlient/pull/252](https://togithub.com/Khan/genqlient/pull/252) - Documentation tweaks relating to releases by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/271](https://togithub.com/Khan/genqlient/pull/271) - Add some better tests for use_struct_references by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/273](https://togithub.com/Khan/genqlient/pull/273) - Add an option to handle enums with ugly casing by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/270](https://togithub.com/Khan/genqlient/pull/270) - Add some more tests for config validation, and fix some gaps by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/274](https://togithub.com/Khan/genqlient/pull/274) - Add consideration for pointer false directive when optional: pointer configuration option is used by [@&open-telemetry#8203;spencermurray](https://togithub.com/spencermurray) in [https://github.com/Khan/genqlient/pull/280](https://togithub.com/Khan/genqlient/pull/280) - Update gqlparser and gqlgen dependencies by [@&open-telemetry#8203;StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/282](https://togithub.com/Khan/genqlient/pull/282) - Update gqlparser to omit comments by [@&open-telemetry#8203;StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/284](https://togithub.com/Khan/genqlient/pull/284) - bugfix: local variable 'data' colliding with argument name by [@&open-telemetry#8203;zholti](https://togithub.com/zholti) in [https://github.com/Khan/genqlient/pull/291](https://togithub.com/Khan/genqlient/pull/291) - Pin lint workflow's Go version by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/311](https://togithub.com/Khan/genqlient/pull/311) - Upgrade golangci-lint and which go we run it with by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/314](https://togithub.com/Khan/genqlient/pull/314) - fix implementation type generation for fragment on a union by [@&open-telemetry#8203;zzh8829](https://togithub.com/zzh8829) in [https://github.com/Khan/genqlient/pull/310](https://togithub.com/Khan/genqlient/pull/310) - Support more valid graphql file extensions by [@&open-telemetry#8203;zzh8829](https://togithub.com/zzh8829) in [https://github.com/Khan/genqlient/pull/309](https://togithub.com/Khan/genqlient/pull/309) - Add tests on Go 1.22, and upgrade x/tools to make them work by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/315](https://togithub.com/Khan/genqlient/pull/315) - Update gqlgen to latest by [@&open-telemetry#8203;StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/317](https://togithub.com/Khan/genqlient/pull/317) - move genqlient Go module to 1.20 by [@&open-telemetry#8203;StevenACoffman](https://togithub.com/StevenACoffman) in [https://github.com/Khan/genqlient/pull/318](https://togithub.com/Khan/genqlient/pull/318) - Improve package-sniffing and bind correctly to types in the same package by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/316](https://togithub.com/Khan/genqlient/pull/316) - Reorganize and improve documentation by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/322](https://togithub.com/Khan/genqlient/pull/322) - Fix non-deterministic generated code involving interfaces and fragments. by [@&open-telemetry#8203;csilvers](https://togithub.com/csilvers) in [https://github.com/Khan/genqlient/pull/323](https://togithub.com/Khan/genqlient/pull/323) - Release v0.7.0 by [@&open-telemetry#8203;benjaminjkraft](https://togithub.com/benjaminjkraft) in [https://github.com/Khan/genqlient/pull/324](https://togithub.com/Khan/genqlient/pull/324) #### New Contributors - [@&open-telemetry#8203;DylanRJohnston](https://togithub.com/DylanRJohnston) made their first contribution in [https://github.com/Khan/genqlient/pull/252](https://togithub.com/Khan/genqlient/pull/252) - [@&open-telemetry#8203;spencermurray](https://togithub.com/spencermurray) made their first contribution in [https://github.com/Khan/genqlient/pull/280](https://togithub.com/Khan/genqlient/pull/280) - [@&open-telemetry#8203;zholti](https://togithub.com/zholti) made their first contribution in [https://github.com/Khan/genqlient/pull/291](https://togithub.com/Khan/genqlient/pull/291) - [@&open-telemetry#8203;zzh8829](https://togithub.com/zzh8829) made their first contribution in [https://github.com/Khan/genqlient/pull/310](https://togithub.com/Khan/genqlient/pull/310) **Full Changelog**: Khan/genqlient@v0.6.0...v0.7.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **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 [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMjAuMiIsInVwZGF0ZWRJblZlciI6IjM3LjIyMC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: opentelemetrybot <[email protected]> Co-authored-by: Andrzej Stencel <[email protected]>
The original motivation here is to fix #283, which is that if you try to use
bindings
to bind to a type in the same package as the generated code, we generate a self-import, which Go doesn't allow. Fixing that is easy -- the three lines inimports.go
-- once you know the package-path of the generated code. (The test that that all fits together is in integration-tests because that was the easiest place to set up the right situation.)Determining the package-path is not too much harder: you ask
go/packages
, which we already use forpackage_bindings
. But once we're doing that, and handling errors, it's kinda silly that we ask you to specify the package your generated code will use, because we have that too, usually. So I rewrote that handling too, makingpackage
now rarely necessary (see for example theexample
config), and warning if it looks wrong. This is the changes inconfig.go
, and is the more substantial non-test change. (I also renamed some of the testdata dirs to be valid package-names, to exercise more of that code, or in the case offind-config
, just for consistency.)I have:
an entrytwo entries to the changelog