Skip to content

Deprecate threadsafe error - #238

Merged
btr-rmconsole-6[bot] merged 1 commit into
masterfrom
cs/deprecate_terr
Oct 1, 2026
Merged

btr-rmconsole-6[bot] merged 1 commit into
masterfrom
cs/deprecate_terr

Conversation

@connorszczepaniak-wk

@connorszczepaniak-wk connorszczepaniak-wk commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

This package is no longer particularly useful in modern Go. A vast majority of use cases I've seen look like this:

wg := &sync.WaitGroup{}
wg.Add(1)
e := terr.New()

go func() {
    defer wg.Done()
    err := doSomething()
    if err != nil {
        e.Set(err)
        return
    }
    // ...
}()

wg.Wait()
if e.Get() != nil {
    return e.Get()
}

Compare this to using an errgroup instead:

eg := &errgroup.Group{}

eg.Go(func() error {
    err := doSomething()
    if err != nil {
        return err
    }
    // ...
}()

err := eg.Wait()
if err != nil {
    return err
}

Far more concise and more idiomatic.

For cases that don't match this, atomic.Pointer[error] is a built-in threadsafe error that requires no additional implementation.

@simeonsteward-wk simeonsteward-wk 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.

+10 adding deprecations needs no testing

@simeonsteward-wk

Copy link
Copy Markdown
Contributor

@Workiva/release-management-p

@rmconsole-wf rmconsole-wf left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

+1 from RM

@btr-rmconsole-6
btr-rmconsole-6 Bot merged commit 8a5dab2 into master Oct 1, 2026
6 checks passed
@hancohaj-spec

Copy link
Copy Markdown

9fc51ad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants