Skip to content

Commit

Permalink
removed backport of strings.Cut and use it instead (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertocavalcante authored Jun 26, 2024
1 parent 46a1511 commit 645e1bc
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,6 @@ func getUserAgent(config config.Config) string {
return fmt.Sprintf("Bazelisk/%s", BazeliskVersion)
}

// TODO(go 1.18): remove backport of strings.Cut
func cutString(s, sep string) (before, after string, found bool) {
if i := strings.Index(s, sep); i >= 0 {
return s[:i], s[i+len(sep):], true
}
return s, "", false
}

func GetBazelVersion(config config.Config) (string, error) {
// Check in this order:
// - env var "USE_BAZEL_VERSION" is set to a specific version.
Expand Down Expand Up @@ -286,7 +278,7 @@ func GetBazelVersion(config config.Config) (string, error) {
}

fallbackVersionFormat := config.Get("USE_BAZEL_FALLBACK_VERSION")
fallbackVersionMode, fallbackVersion, hasFallbackVersionMode := cutString(fallbackVersionFormat, ":")
fallbackVersionMode, fallbackVersion, hasFallbackVersionMode := strings.Cut(fallbackVersionFormat, ":")
if !hasFallbackVersionMode {
fallbackVersionMode, fallbackVersion, hasFallbackVersionMode = "silent", fallbackVersionMode, true
}
Expand Down

0 comments on commit 645e1bc

Please sign in to comment.