Skip to content

feat(internal/config): add default_enabled_generator_features to Go configuration#6029

Merged
suztomo merged 2 commits into
googleapis:mainfrom
suztomo:issue-5246-default-features
May 18, 2026
Merged

feat(internal/config): add default_enabled_generator_features to Go configuration#6029
suztomo merged 2 commits into
googleapis:mainfrom
suztomo:issue-5246-default-features

Conversation

@suztomo

@suztomo suztomo commented May 15, 2026

Copy link
Copy Markdown
Member

This change introduces default_enabled_generator_features in librarian.yaml's default.go section and updates Librarian to append these defaults to APIs' go.enabled_generator_features list.

It implements a union helper to merge default generator features with API-specific ones while de-duplicating elements and preserving their original insertion order. This custom helper is necessary as the Go standard library does not provide a built-in order-preserving de-duplication helper for slices. Preserving the order of generator features is important because it ensures the generated protoc command line remains consistent across runs.

The companion pull request is googleapis/google-cloud-go#14600. The librarian change needs to happen first. After that, I'll update the librarian version in librarian.yaml in google-cloud-go with a pseudo version with the default value added there.

Fixes #5246

@suztomo suztomo requested a review from a team as a code owner May 15, 2026 16:58
@suztomo suztomo marked this pull request as draft May 15, 2026 16:58

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a mechanism to define default generator features for Go APIs. Changes include updating the configuration schema, adding a DefaultEnabledGeneratorFeatures field to the Go configuration struct, and implementing the fillGo function to apply these defaults when API-specific features are missing. Feedback suggests removing the unnecessary initialization of lib.Go in the fillGo function, as it only modifies API-level configurations.

Comment thread internal/librarian/library.go Outdated
Comment thread internal/librarian/library.go Outdated
@suztomo suztomo force-pushed the issue-5246-default-features branch 4 times, most recently from 53d2302 to cfcb10d Compare May 18, 2026 15:08
@suztomo suztomo changed the title feat: add default_enabled_generator_features to Go configuration feat(internal/config): add default_enabled_generator_features to Go configuration May 18, 2026
@suztomo suztomo force-pushed the issue-5246-default-features branch from a528a83 to 589e983 Compare May 18, 2026 15:47
@suztomo suztomo marked this pull request as ready for review May 18, 2026 15:47
@suztomo suztomo requested review from JoeWang1127 and zhumin8 May 18, 2026 15:47
Comment thread internal/librarian/library_test.go
Comment thread internal/librarian/library.go
Comment thread .github/workflows/go.yaml Outdated
This change introduces default_enabled_generator_features in librarian.yaml's default.go section and updates Librarian to apply these defaults to APIs with empty go configuration.

It implements a `union` helper to merge default generator features with API-specific ones while de-duplicating elements and preserving their original insertion order. This custom helper is necessary as the Go standard library does not provide a built-in order-preserving de-duplication helper for slices.

Fixes googleapis#5246

TAG=agy
CONV=dc5bc0de-b49f-4b0d-ab5c-5e44d6ecd975
@suztomo suztomo force-pushed the issue-5246-default-features branch from 589e983 to d5182d5 Compare May 18, 2026 17:23

@suztomo suztomo left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread internal/librarian/library.go
Comment thread internal/librarian/library_test.go
Comment thread .github/workflows/go.yaml Outdated

@JoeWang1127 JoeWang1127 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add a test to verify nil GoDefault?

@JoeWang1127

Copy link
Copy Markdown
Contributor

Could you update the pull request description?

@suztomo

suztomo commented May 18, 2026

Copy link
Copy Markdown
Member Author

Updated the description:

  • The defaults are appended to the go.enabled_generator_features.
  • The integration test with google-cloud-go is not skipped.

@suztomo suztomo merged commit 04b8e64 into googleapis:main May 18, 2026
25 checks passed
@suztomo suztomo deleted the issue-5246-default-features branch May 18, 2026 18:10
suztomo added a commit to googleapis/google-cloud-go that referenced this pull request May 18, 2026
…#14600)

This change adds default_enabled_generator_features under `default.go` and
removes redundant enabled_generator_features from individual APIs where
they match the default.

The companion pull request is
googleapis/librarian#6029. The librarian change
needs to happen first. After that, I'll update the librarian version in
`librarian.yaml` in google-cloud-go with a pseudo version. => It is
`v0.13.2-0.20260518181009-04b8e642ea4c`.

I regenerated the code using the pseudo version:

```
suztomo@suztomo:~/librarian-2026/google-cloud-go$ echo $V
v0.13.2-0.20260518181009-04b8e642ea4c
suztomo@suztomo:~/librarian-2026/google-cloud-go$ go run github.com/googleapis/librarian/cmd/librarian@${V} generate --all
```

This fixes `maps/mapmanagement/apiv2beta/map_management_client.go` being
generated without the `F_open_telemetry_attributes` option (details:
googleapis/librarian#5246 (comment)).

Fixes googleapis/librarian#5246
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.

golang: add GoModule in Default configuration

2 participants