Skip to content

Commit 32e8998

Browse files
committed
builtin: spring cleaning
1 parent 9d89a00 commit 32e8998

1 file changed

Lines changed: 1 addition & 32 deletions

File tree

builtin/builtin.go

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import (
1515
// - visitedItems := map[string]Void{}
1616
type Void struct{}
1717

18-
// ignores error in situations where context was canceled and thus errors are to be expected
19-
// and thus are non-interesting
18+
// ignores error in situations where context was canceled and thus errors are to be expected / normal.
2019
func IgnoreErrorIfCanceled(ctx context.Context, err error) error {
2120
select {
2221
case <-ctx.Done():
@@ -34,17 +33,6 @@ func Pointer[T any](val T) *T {
3433
return &val
3534
}
3635

37-
// helper for wrapping an error with error prefix.
38-
// if error is nil, nil is returned.
39-
// Deprecated: this doesn't carry its own weight - just use `fmt.Errorf()`
40-
func ErrorWrap(prefix string, err error) error {
41-
if err != nil {
42-
return fmt.Errorf("%s: %w", prefix, err)
43-
} else {
44-
return nil
45-
}
46-
}
47-
4836
// errors if a field is unset. it is up to the caller to evaluate if the field is unset
4937
func ErrorIfUnset(isUnset bool, fieldName string) error {
5038
if isUnset {
@@ -54,18 +42,6 @@ func ErrorIfUnset(isUnset bool, fieldName string) error {
5442
}
5543
}
5644

57-
// returns the first non-empty value.
58-
// Deprecated: use `cmp.Or()`
59-
func FirstNonEmpty[T comparable](values ...T) T {
60-
var empty T
61-
for _, value := range values {
62-
if value != empty {
63-
return value
64-
}
65-
}
66-
return empty
67-
}
68-
6945
// for a function that returns two values, you can get the value with `Must(fn())` to convert it to
7046
// the value, panicking if producing the value caused an error
7147
func Must[T any](value T, err error) T {
@@ -76,13 +52,6 @@ func Must[T any](value T, err error) T {
7652
return value
7753
}
7854

79-
// returns first error, or nil if no errors
80-
// Deprecated: use `FirstNonEmpty()`
81-
func FirstError(errs ...error) error {
82-
return FirstNonEmpty(errs...)
83-
}
84-
85-
8655
// append to a slice without needing the "assign to same variable" boilerplate
8756
func Append[T any](slice *[]T, item T) {
8857
*slice = append(*slice, item)

0 commit comments

Comments
 (0)