diff --git a/Makefile b/Makefile index 1cc45c1830..a2a2583ca4 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,9 @@ DEB_HASH=$(shell git rev-parse HEAD) export GO111MODULE=on -.PHONY: vendor vetcheck fmtcheck clean build gotest update-go-deps +.PHONY: vendor vetcheck modernize-check fmtcheck clean build gotest update-go-deps -all: vendor vetcheck fmtcheck gotest mod-clean build-node-native +all: vendor vetcheck modernize-check fmtcheck gotest mod-clean build-node-native ci: vendor vetcheck fmtcheck release-node build-importer-native gotest-race-coverage mod-clean @@ -71,6 +71,12 @@ vetcheck: golangci-lint run -c .golangci.yml golangci-lint run -c .golangci-strict.yml --new-from-rev=origin/master +modernize-check: + @bash -lc 'set -o pipefail; \ + output=$$(go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest ./... 2>&1 | \ + grep -vE "\.(pb|gen)\.go|mock|_string.go|^exit status|^go: downloading"); \ + [ -n "$$output" ] && { echo "$$output"; exit 1; } || exit 0;' + strict-vet-check: golangci-lint run -c .golangci-strict.yml diff --git a/pkg/ride/functions_strings.go b/pkg/ride/functions_strings.go index 6ed7170cff..0be10d814e 100644 --- a/pkg/ride/functions_strings.go +++ b/pkg/ride/functions_strings.go @@ -457,10 +457,11 @@ func contains(_ environment, args ...rideType) (rideType, error) { } func runesIndex(s, sub string) int { - if i := strings.Index(s, sub); i >= 0 { - return utf8.RuneCountInString(s[:i]) + before, _, ok := strings.Cut(s, sub) + if !ok { + return -1 } - return -1 + return utf8.RuneCountInString(before) } func runesDrop(s string, n int) string {