Skip to content

proposal: add func Must[T any](value T, err error) T #64398

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

Closed
it512 opened this issue Nov 27, 2023 · 1 comment
Closed

proposal: add func Must[T any](value T, err error) T #64398

it512 opened this issue Nov 27, 2023 · 1 comment

Comments

@it512
Copy link

it512 commented Nov 27, 2023

Proposal Details

add function Must[T any](value T, err error) T

Too many function return value and error , and a lot of library and golang implement Must(x, error) .

func Must[T any](value T, err error) T{
    if err != nil {
        panic(err)
    }
    return value
}

put into errors package?

@it512 it512 added the Proposal label Nov 27, 2023
@gopherbot gopherbot added this to the Proposal milestone Nov 27, 2023
@ALTree
Copy link
Member

ALTree commented Nov 27, 2023

This is #54297 and #60846, closing in favour of the older thread.

@ALTree ALTree closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
@golang golang locked and limited conversation to collaborators Nov 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants