chore: fix issues with Go 1.18 in CI (#416)

This commit is contained in:
Dane Strandboge
2022-06-27 15:11:12 -05:00
committed by GitHub
parent d3e0efb560
commit 56a8276a4a
6 changed files with 16 additions and 42 deletions

View File

@ -6,6 +6,7 @@ import (
"io"
"net/url"
"runtime"
"strings"
"github.com/influxdata/influx-cli/v2/api"
"github.com/influxdata/influx-cli/v2/clients"
@ -96,7 +97,7 @@ func newApiClient(ctx *cli.Context, configSvc config.Service, injectToken bool)
if ctx.IsSet(extraHttpHeaderFlagName) {
for _, h := range ctx.StringSlice(extraHttpHeaderFlagName) {
k, v, ok := stringsCut(h, ":")
k, v, ok := strings.Cut(h, ":")
if !ok {
return nil, fmt.Errorf(`header flag syntax "key:value", missing value in %q`, h)
}

View File

@ -1,9 +0,0 @@
//go:build go1.18
package main
import "strings"
func stringsCut(s, sep string) (before, after string, found bool) {
return strings.Cut(s, sep)
}

View File

@ -1,16 +0,0 @@
//go:build !go1.18
// remove this backward compat shim once we either:
// a) upgrade cross-builder docker image in https://github.com/influxdata/edge/
// b) switch the CI system for this repo away from using cross-builder docker image.
package main
import "strings"
func stringsCut(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
}