"reflect"
"regexp"
"runtime"
+ "slices"
"strconv"
"strings"
"time"
if len(t.runNames) == 0 {
return true
}
- for _, runName := range t.runNames {
- if runName == name {
- return true
- }
- }
- return false
+ return slices.Contains(t.runNames, name)
}
func (t *tester) maybeLogMetadata() error {
"io"
"io/fs"
"path/filepath"
+ "slices"
"sort"
"strings"
"unicode"
}
// other tags
- for _, tag := range ctxt.BuildTags {
- if tag == name {
- return true
- }
- }
- for _, tag := range ctxt.ToolTags {
- if tag == name {
- return true
- }
- }
- for _, tag := range ctxt.ReleaseTags {
- if tag == name {
- return true
- }
- }
-
- return false
+ return slices.Contains(ctxt.BuildTags, name) || slices.Contains(ctxt.ToolTags, name) ||
+ slices.Contains(ctxt.ReleaseTags, name)
}
// goodOSArchFile returns false if the name contains a $GOOS or $GOARCH
}
// Don't send tickets the client wouldn't use. See RFC 8446, Section 4.2.9.
- for _, pskMode := range hs.clientHello.pskModes {
- if pskMode == pskModeDHE {
- return true
- }
- }
- return false
+ return slices.Contains(hs.clientHello.pskModes, pskModeDHE)
}
func (hs *serverHandshakeStateTLS13) sendSessionTickets() error {
}
// other tags
- for _, tag := range ctxt.BuildTags {
- if tag == name {
- return true
- }
- }
- for _, tag := range ctxt.ToolTags {
- if tag == name {
- return true
- }
- }
- for _, tag := range ctxt.ReleaseTags {
- if tag == name {
- return true
- }
- }
-
- return false
+ return slices.Contains(ctxt.BuildTags, name) || slices.Contains(ctxt.ToolTags, name) ||
+ slices.Contains(ctxt.ReleaseTags, name)
}
// goodOSArchFile returns false if the name contains a $GOOS or $GOARCH
"os"
"path/filepath"
"runtime"
+ "slices"
"strings"
"sync"
"testing"
return v
}
func (v visitor) filter(name string) bool {
- for _, typeName := range typeNames {
- if typeName == name {
- return true
- }
- }
- return false
+ return slices.Contains(typeNames, name)
}
func (v visitor) Visit(n ast.Node) ast.Visitor {
import (
"fmt"
+ "slices"
"strings"
"internal/trace/event"
// hasRange returns true if a special time range on the goroutine as in progress.
func (s *rangeState) hasRange(typ rangeType) bool {
- for _, ftyp := range s.inFlight {
- if ftyp == typ {
- return true
- }
- }
- return false
+ return slices.Contains(s.inFlight, typ)
}
// endRange ends a special range in time on the goroutine.
import (
"os"
+ "slices"
"testing"
)
if err != nil {
t.Fatalf("%+v.GroupIds(): %v", user, err)
}
- if !containsID(gids, user.Gid) {
+ if !slices.Contains(gids, user.Gid) {
t.Errorf("%+v.GroupIds() = %v; does not contain user GID %s", user, gids, user.Gid)
}
}
-
-func containsID(ids []string, id string) bool {
- for _, x := range ids {
- if x == id {
- return true
- }
- }
- return false
-}
"os"
"os/exec"
"runtime"
+ "slices"
"strconv"
"syscall"
"testing"
if err != nil {
t.Fatalf("%+v.GroupIds(): %v", user, err)
}
- if !containsID(gids, user.Gid) {
+ if !slices.Contains(gids, user.Gid) {
t.Errorf("%+v.GroupIds() = %v; does not contain user GID %s", user, gids, user.Gid)
}
}
"internal/itoa"
runtimesyscall "internal/runtime/syscall"
"runtime"
+ "slices"
"unsafe"
)
return false
}
- for _, g := range groups {
- if g == gid {
- return true
- }
- }
- return false
+ return slices.Contains(groups, gid)
}
func isCapDacOverrideSet() bool {