diff --git a/CHANGELOG.md b/CHANGELOG.md index dfe1bfd2b..4ffe21a59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Bugfixes - [#2253](https://github.com/influxdata/kapacitor/pull/2253): Upgrade the kafka library to set the timestamp correctly. +- [#2274](https://github.com/influxdata/kapacitor/pull/2274): Upgrade to Go 1.13, fixes various go vet issues. ## v1.5.3 [2019-06-18] diff --git a/Dockerfile_build_ubuntu32 b/Dockerfile_build_ubuntu32 index 04952da20..a18404bea 100644 --- a/Dockerfile_build_ubuntu32 +++ b/Dockerfile_build_ubuntu32 @@ -33,7 +33,7 @@ RUN wget -q https://github.com/google/protobuf/releases/download/v${PROTO_VERSIO # Install go ENV GOPATH /root/go -ENV GO_VERSION 1.11.2 +ENV GO_VERSION 1.13.6 ENV GO_ARCH 386 RUN wget -q https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz; \ tar -C /usr/local/ -xf /go${GO_VERSION}.linux-${GO_ARCH}.tar.gz ; \ diff --git a/Dockerfile_build_ubuntu64 b/Dockerfile_build_ubuntu64 index e503c0561..33f1d6a78 100644 --- a/Dockerfile_build_ubuntu64 +++ b/Dockerfile_build_ubuntu64 @@ -43,7 +43,7 @@ RUN wget -q https://github.com/google/protobuf/releases/download/v${PROTO_VERSIO # Install go ENV GOPATH /root/go -ENV GO_VERSION 1.11.2 +ENV GO_VERSION 1.13.6 ENV GO_ARCH amd64 RUN wget -q https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz; \ tar -C /usr/local/ -xf /go${GO_VERSION}.linux-${GO_ARCH}.tar.gz ; \ diff --git a/build.py b/build.py index d682f51e4..5175f0c3c 100755 --- a/build.py +++ b/build.py @@ -47,7 +47,7 @@ DESCRIPTION = "Time series data processing engine" # SCRIPT START -go_vet_command = "go tool vet -composites=false" +go_vet_command = "go vet ./..." prereqs = [ 'git', 'go' ] optional_prereqs = [ 'fpm', 'rpmbuild', 'gpg' ] @@ -161,8 +161,7 @@ def run_generate(): run("go install ./vendor/github.com/golang/protobuf/protoc-gen-go") run("go install ./vendor/github.com/benbjohnson/tmpl") run("go install ./vendor/github.com/mailru/easyjson/easyjson") - generate_cmd = ["go", "generate"] - generate_cmd.extend(go_list()) + generate_cmd = ["go", "generate", "./..."] p = subprocess.Popen(generate_cmd) code = p.wait() if code == 0: @@ -201,13 +200,13 @@ def run_tests(race, parallel, timeout, no_vet): logging.info("Using parallel: {}".format(parallel)) if timeout is not None: logging.info("Using timeout: {}".format(timeout)) - out = run("go fmt {}".format(' '.join(go_list()))) + out = run("go fmt ./...") if len(out) > 0: logging.error("Code not formatted. Please use 'go fmt ./...' to fix formatting errors.") logging.error("{}".format(out)) return False if not no_vet: - vet_cmd = go_vet_command + " {}".format(" ".join(go_list(relative=True))) + vet_cmd = go_vet_command out = run(vet_cmd) if len(out) > 0: logging.error("Go vet failed. Please run '{}' and fix any errors.".format(vet_cmd)) @@ -215,14 +214,14 @@ def run_tests(race, parallel, timeout, no_vet): return False else: logging.info("Skipping 'go vet' call...") - test_command = "go test -v" + test_command = "go test" if race: test_command += " -race" if parallel is not None: test_command += " -parallel {}".format(parallel) if timeout is not None: test_command += " -timeout {}".format(timeout) - test_command += " {}".format(' '.join(go_list())) + test_command += " ./..." logging.info("Running tests...") output = run(test_command, printOutput=logging.getLogger().getEffectiveLevel() == logging.DEBUG) return True @@ -488,32 +487,6 @@ def upload_packages(packages, bucket_name=None, overwrite=False): logging.warn("Not uploading file {}, as it already exists in the target bucket.".format(name)) return True -def go_list(vendor=False, relative=False): - """ - Return a list of packages - If vendor is False vendor package are not included - If relative is True the package prefix defined by PACKAGE_URL is stripped - """ - p = subprocess.Popen(["go", "list", "./..."], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - packages = out.split('\n') - if packages[-1] == '': - packages = packages[:-1] - if not vendor: - non_vendor = [] - for p in packages: - if '/vendor/' not in p: - non_vendor.append(p) - packages = non_vendor - if relative: - relative_pkgs = [] - for p in packages: - r = p.replace(PACKAGE_URL, '.') - if r != '.': - relative_pkgs.append(r) - packages = relative_pkgs - return packages - def build(version=None, platform=None, arch=None, diff --git a/expvar/expvar.go b/expvar/expvar.go index b6a23e626..afdaca1b1 100644 --- a/expvar/expvar.go +++ b/expvar/expvar.go @@ -260,7 +260,7 @@ func (v *Map) DoSorted(f func(expvar.KeyValue)) { } sort.Strings(keys) for _, k := range keys { - f(expvar.KeyValue{k, v.m[k]}) + f(expvar.KeyValue{Key: k, Value: v.m[k]}) } } @@ -268,7 +268,7 @@ func (v *Map) DoSorted(f func(expvar.KeyValue)) { // v.mu must be held for reads. func (v *Map) doLocked(f func(expvar.KeyValue)) { for k, v := range v.m { - f(expvar.KeyValue{k, v}) + f(expvar.KeyValue{Key: k, Value: v}) } } diff --git a/integrations/streamer_test.go b/integrations/streamer_test.go index 2496dfd68..43867f975 100644 --- a/integrations/streamer_test.go +++ b/integrations/streamer_test.go @@ -76,7 +76,7 @@ import ( "github.com/influxdata/kapacitor/services/victorops/victoropstest" "github.com/influxdata/kapacitor/udf" "github.com/influxdata/kapacitor/udf/agent" - "github.com/influxdata/kapacitor/udf/test" + udf_test "github.com/influxdata/kapacitor/udf/test" "github.com/influxdata/wlog" "github.com/k-sone/snmpgo" ) @@ -84,6 +84,7 @@ import ( var diagService *diagnostic.Service func init() { + testing.Init() flag.Parse() out := ioutil.Discard if testing.Verbose() { @@ -7091,7 +7092,7 @@ stream exp.Values = []*agent.OptionValue{ { Type: agent.ValueType_STRING, - Value: &agent.OptionValue_StringValue{"count"}, + Value: &agent.OptionValue_StringValue{StringValue: "count"}, }, } case 1: @@ -7099,23 +7100,23 @@ stream exp.Values = []*agent.OptionValue{ { Type: agent.ValueType_BOOL, - Value: &agent.OptionValue_BoolValue{false}, + Value: &agent.OptionValue_BoolValue{BoolValue: false}, }, { Type: agent.ValueType_INT, - Value: &agent.OptionValue_IntValue{1}, + Value: &agent.OptionValue_IntValue{IntValue: 1}, }, { Type: agent.ValueType_DOUBLE, - Value: &agent.OptionValue_DoubleValue{1.0}, + Value: &agent.OptionValue_DoubleValue{DoubleValue: 1.0}, }, { Type: agent.ValueType_STRING, - Value: &agent.OptionValue_StringValue{"1.0"}, + Value: &agent.OptionValue_StringValue{StringValue: "1.0"}, }, { Type: agent.ValueType_DURATION, - Value: &agent.OptionValue_DurationValue{int64(time.Second)}, + Value: &agent.OptionValue_DurationValue{DurationValue: int64(time.Second)}, }, } } diff --git a/pipeline/udf.go b/pipeline/udf.go index 881ca7147..f1225b82a 100644 --- a/pipeline/udf.go +++ b/pipeline/udf.go @@ -134,19 +134,19 @@ func (u *UDFNode) SetProperty(name string, args ...interface{}) (interface{}, er switch v := arg.(type) { case bool: values[i].Type = agent.ValueType_BOOL - values[i].Value = &agent.OptionValue_BoolValue{v} + values[i].Value = &agent.OptionValue_BoolValue{BoolValue: v} case int64: values[i].Type = agent.ValueType_INT - values[i].Value = &agent.OptionValue_IntValue{v} + values[i].Value = &agent.OptionValue_IntValue{IntValue: v} case float64: values[i].Type = agent.ValueType_DOUBLE - values[i].Value = &agent.OptionValue_DoubleValue{v} + values[i].Value = &agent.OptionValue_DoubleValue{DoubleValue: v} case string: values[i].Type = agent.ValueType_STRING - values[i].Value = &agent.OptionValue_StringValue{v} + values[i].Value = &agent.OptionValue_StringValue{StringValue: v} case time.Duration: values[i].Type = agent.ValueType_DURATION - values[i].Value = &agent.OptionValue_DurationValue{int64(v)} + values[i].Value = &agent.OptionValue_DurationValue{DurationValue: int64(v)} } if values[i].Type != opt.ValueTypes[i] { return nil, fmt.Errorf("unexpected arg to %s, got %v expected %v", name, values[i].Type, opt.ValueTypes[i]) @@ -219,14 +219,14 @@ func (u *UDFNode) unmarshal(props JSONNode) error { case bool: values[i] = &agent.OptionValue{ Type: agent.ValueType_BOOL, - Value: &agent.OptionValue_BoolValue{v}, + Value: &agent.OptionValue_BoolValue{BoolValue: v}, } case json.Number: integer, err := v.Int64() if err == nil { values[i] = &agent.OptionValue{ Type: agent.ValueType_INT, - Value: &agent.OptionValue_IntValue{integer}, + Value: &agent.OptionValue_IntValue{IntValue: integer}, } break } @@ -237,20 +237,20 @@ func (u *UDFNode) unmarshal(props JSONNode) error { } values[i] = &agent.OptionValue{ Type: agent.ValueType_DOUBLE, - Value: &agent.OptionValue_DoubleValue{flt}, + Value: &agent.OptionValue_DoubleValue{DoubleValue: flt}, } case string: dur, err := influxql.ParseDuration(v) if err == nil { values[i] = &agent.OptionValue{ Type: agent.ValueType_DURATION, - Value: &agent.OptionValue_DurationValue{int64(dur)}, + Value: &agent.OptionValue_DurationValue{DurationValue: int64(dur)}, } break } values[i] = &agent.OptionValue{ Type: agent.ValueType_STRING, - Value: &agent.OptionValue_StringValue{v}, + Value: &agent.OptionValue_StringValue{StringValue: v}, } } } diff --git a/services/pushover/service.go b/services/pushover/service.go index 8fe9c1329..e9ad87dc8 100644 --- a/services/pushover/service.go +++ b/services/pushover/service.go @@ -114,7 +114,7 @@ func (s *Service) Alert(message, device, title, URL, URLTitle, sound string, lev pushoverResponse := struct { Errors []string `json:"errors"` }{} - err = json.Unmarshal(body, pushoverResponse) + err = json.Unmarshal(body, &pushoverResponse) if err != nil { return err } diff --git a/udf/server.go b/udf/server.go index d6da85ae9..42e70ffb5 100644 --- a/udf/server.go +++ b/udf/server.go @@ -303,7 +303,7 @@ func (s *Server) Snapshot() ([]byte, error) { // Request to restore a snapshot. func (s *Server) Restore(snapshot []byte) error { req := &agent.Request{Message: &agent.Request_Restore{ - Restore: &agent.RestoreRequest{snapshot}, + Restore: &agent.RestoreRequest{Snapshot: snapshot}, }} resp, err := s.doRequestResponse(req, s.restoreResponse) if err != nil {