Repository navigation
feat!: narrow unions with UnionAs and name member lists Types - #7
Merged
Merged
Conversation
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
enilsen16
added this pull request to stack #9
October 22, 2026 14:17
Signed-off-by: Erik Nilsen <enilsen16@live.com>
…options Signed-off-by: Erik Nilsen <enilsen16@live.com>
…ition Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
…options Signed-off-by: Erik Nilsen <enilsen16@live.com> # Conflicts: # objectid_test.go
…d-checks Signed-off-by: Erik Nilsen <enilsen16@live.com> # Conflicts: # objectid.go # objectidproto/objectidproto.go # objectidproto/objectidproto_test.go
…n errors Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
…-options Signed-off-by: Erik Nilsen <enilsen16@live.com> # Conflicts: # objectid.go # objectid_test.go
Signed-off-by: Erik Nilsen <enilsen16@live.com>
…-options Signed-off-by: Erik Nilsen <enilsen16@live.com> # Conflicts: # objectid.go # objectid_test.go
…d-checks Signed-off-by: Erik Nilsen <enilsen16@live.com> # Conflicts: # objectid.go
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
This file contains hidden or 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
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.
Stacked on #6.
Summary
UnionAs[T](u)returns the union's member as anID[T]. It returns false when the union holds another type or is zero. A caller can then narrow a union without a type switch, which replaces umbrella'sto_fan_actor_id-style helpers.UnionDefiner.Members()is nowTypes(), to match the Elixiruse Trogon.UnionObjectId, types: [...].MemberOf[T]()keeps its name, becauseTypeOfreads likereflect.TypeOf. This is a breaking change before v1.Tests
TestUnionAscovers the matching member, another member, and the zero union. The existing union tests use the new names. CI runs only on PRs tomain. Locally,go test -race,go vetand golangci-lint pass.Need help on this PR? Tag
@codesmith-botwith what you need.