Skip to content
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

feat: new method for fetching ignoring error #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lzap
Copy link

@lzap lzap commented Mar 20, 2025

This may sound crazy, but I am working on a codebase where we use OpenAPI schema to describe a (YAML) document. All fields (except document name) are optional so I have to work with many optional fiels. While I want to explore the new feature omitzero, I am evaluating nullable to do the heavylifting and I am not even sure if this is gonna work yet.

But I would love to have a method - workting title - Dig that does exactly what Get does but ignores the error and returns an empty value. Assuming that all fields within structs are also treated with nullable my theory is this can simulate behavior of omitzero.

a := value.Field.Dig().Field.Dig()

Am I crazy? I think I am. Well, let’s hear from others. I am unsure about the name for such method, but I want something that is short so I came up with Dig which is probably too wild. But GetWithoutError would not work that is way too long. Also this does not have tests yet because I am unsure if you like this or if there are not flaws in my idea.

@lzap lzap requested a review from a team as a code owner March 20, 2025 11:04
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.

1 participant