Skip to content

Commit

Permalink
chore(go): update to Go 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc committed Jan 10, 2020
1 parent de764ae commit 776c4be
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 56 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile_build_ubuntu32
Original file line number Diff line number Diff line change
Expand Up @@ -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 ; \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile_build_ubuntu64
Original file line number Diff line number Diff line change
Expand Up @@ -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 ; \
Expand Down
39 changes: 6 additions & 33 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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' ]

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -201,28 +200,28 @@ 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))
logging.error("{}".format(out))
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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions expvar/expvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ 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]})
}
}

// doLocked calls f for each entry in the map.
// 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})
}
}

Expand Down
15 changes: 8 additions & 7 deletions integrations/streamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ 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"
)

var diagService *diagnostic.Service

func init() {
testing.Init()
flag.Parse()
out := ioutil.Discard
if testing.Verbose() {
Expand Down Expand Up @@ -7091,31 +7092,31 @@ stream
exp.Values = []*agent.OptionValue{
{
Type: agent.ValueType_STRING,
Value: &agent.OptionValue_StringValue{"count"},
Value: &agent.OptionValue_StringValue{StringValue: "count"},
},
}
case 1:
exp.Name = "opt2"
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)},
},
}
}
Expand Down
20 changes: 10 additions & 10 deletions pipeline/udf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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
}
Expand All @@ -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},
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion services/pushover/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion udf/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 776c4be

Please sign in to comment.