Skip to content

Commit

Permalink
Don't use "slices"
Browse files Browse the repository at this point in the history
  • Loading branch information
tdeebswihart committed Dec 8, 2023
1 parent b7556b7 commit 41ecb53
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/protogen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"os/signal"
"path/filepath"
"regexp"
"slices"
"strings"

"go.temporal.io/api/internal/errgroup"
Expand Down Expand Up @@ -260,6 +259,16 @@ func fail(msg string, args ...any) {
os.Exit(1)
}

// Contains reports whether v is present in s.
func sliceContains[S ~[]E, E comparable](haystack S, needle E) bool {
for i := 0; i < len(haystack); i++ {
if needle == haystack[i] {
return true
}
}
return false
}

func main() {
var protoRootDir, outputDir, enumPrefixPairs string
var protoPlugins, protoIncludes, excludeDirs stringArr
Expand All @@ -282,7 +291,7 @@ func main() {
}

// Always include the root dir
if !slices.Contains(protoIncludes, protoRootDir) {
if !sliceContains(protoIncludes, protoRootDir) {
protoIncludes = append(protoIncludes, protoRootDir)
}
// Cancel everything if we receive SIGINT or SIGSTOP
Expand Down

0 comments on commit 41ecb53

Please sign in to comment.