| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
This pull request enhances the generic type normalization logic to properly preserve pointer types in generic iterators, specifically addressing the need to handle types like iter.Seq2[*github.Artifact, error] where pointer prefixes must be maintained.
Changes:
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| interfaces/generate.go | Refactored type normalization logic by extracting pointer handling into normalizeFullTypeName and updating normalizedGenericTypeName to support multiple type parameters |
| interfaces/generate_test.go | Added comprehensive unit tests for normalizedGenericTypeName covering single/multiple type parameters, pointer types, and versioned imports |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| typeName = typeName[1:] | ||
| } | ||
|
|
||
| versionPattern := regexp.MustCompile(`/v\d+\.`) |
There was a problem hiding this comment.
The regex pattern is compiled on every function call. Since this function may be called multiple times during code generation (once per type parameter), consider moving the regex compilation to a package-level variable to improve performance. For example, declare var versionPattern = regexp.MustCompile(\/v\d+\.`)` at the package level and reuse it in this function.
Sorry, something went wrong.
| // Generic output types have the full import path in the string value, so we need to normalize it | ||
| pattern := regexp.MustCompile(`\[(.*?)\]`) | ||
| groups := pattern.FindStringSubmatch((str)) | ||
| pattern := regexp.MustCompile(`\[(.*)\]`) |
There was a problem hiding this comment.
The regex pattern is compiled on every function call. Since this function is called for each return type in method signatures, consider moving the regex compilation to a package-level variable to improve performance. For example, declare var genericTypePattern = regexp.MustCompile(\\[(.*)\]`)` at the package level and reuse it in this function.
Sorry, something went wrong.
| if versionPattern.MatchString(typeName) { | ||
| // Example typeName: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appconfiguration/armappconfiguration/v2.ConfigurationStoresClientCreateResponse | ||
| importName = parts[len(parts)-2] + "." + strings.Split(parts[len(parts)-1], ".")[1] |
There was a problem hiding this comment.
Potential index out of bounds error. The code assumes that when versionPattern matches, parts[len(parts)-1] (the last path segment) will contain a dot and can be safely split to access index [1]. While this is true for well-formed versioned import paths like armappconfiguration/v2.ConfigurationStoresClientListResponse, malformed input could cause a panic. Consider adding a bounds check or using a more defensive approach, such as checking the length of the split result before accessing index [1].
| if versionPattern.MatchString(typeName) { | |
| // Example typeName: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appconfiguration/armappconfiguration/v2.ConfigurationStoresClientCreateResponse | |
| importName = parts[len(parts)-2] + "." + strings.Split(parts[len(parts)-1], ".")[1] | |
| if versionPattern.MatchString(typeName) && len(parts) >= 2 { | |
| // Example typeName: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appconfiguration/armappconfiguration/v2.ConfigurationStoresClientCreateResponse | |
| lastParts := strings.Split(parts[len(parts)-1], ".") | |
| if len(lastParts) >= 2 { | |
| importName = parts[len(parts)-2] + "." + lastParts[1] | |
| } |
Sorry, something went wrong.
🤖 I have created a release *beep* *boop* --- ## [0.3.37](v0.3.36...v0.3.37) (2026-02-17) ### Features * Preserve pointer types in generic iterators ([#409](#409)) ([d4fe386](d4fe386)) ### Bug Fixes * **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.94.2 ([#407](#407)) ([41c4bc3](41c4bc3)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
| Back | FazBrowse Home | New Git URL |
Release-As: v0.4.0