Skip to content

Commit

Permalink
Fix some Go 1.11 issues. (#2149)
Browse files Browse the repository at this point in the history
* Fix some Go 1.11 issues.

In Go 1.11, functions called by the template package are always
handed two arguments, instead of one or conditionally two.

This commit also fixes some formatting directives that were not
previously noticed by the old go vet.

Closes #2073

Signed-off-by: Eric Chlebek <eric@sensu.io>

* Remove an unused var.

Signed-off-by: Eric Chlebek <eric@sensu.io>
  • Loading branch information
echlebek authored Oct 9, 2018
1 parent 3513a70 commit f0d39c1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ were being displayed rather than the check's current values.
- Use the provided etcd client TLS information when the flag `--no-embed-etcd`
is used.
- Increase duration delta in TestPeriodicKeepalive integration test.
- Fixed some problems introduced by Go 1.11.

### Breaking Changes
- Removed the KeepaliveTimeout attribute from entities.
Expand Down
3 changes: 3 additions & 0 deletions agent/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func defaultFunc(v ...interface{}) interface{} {
if len(v) == 1 {
return v[0]
} else if len(v) == 2 {
if v[1] == nil {
return v[0]
}
return v[1]
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions backend/monitor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (m *EtcdSupervisor) Monitor(ctx context.Context, name string, event *types.
}

shutdownFunc := func() {
logger.Info("shutting down monitor for %s", key)
logger.Infof("shutting down monitor for %s", key)
}

// start the watcher
Expand Down Expand Up @@ -172,7 +172,7 @@ func watchMon(ctx context.Context, cli *clientv3.Client, mon *monitor, failureHa
)

if _, err := cli.Lease.Revoke(ctx, mon.leaseID); err != nil {
logger.WithError(err).Warningf("could not revoke the lease %s for the key %s",
logger.WithError(err).Warningf("could not revoke the lease %v for the key %s",
mon.leaseID, mon.key,
)
}
Expand Down
2 changes: 0 additions & 2 deletions backend/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ func TestDequeueParallel(t *testing.T) {
// If we had multiple errors, only the last one is saved
require.NoError(t, errEnqueue)
results := make(map[string]struct{})
var errDequeue error
wg.Add(len(items))
for range items {
go func() {
Expand All @@ -245,7 +244,6 @@ func TestDequeueParallel(t *testing.T) {
mu.Lock()
defer mu.Unlock()
if err != nil {
errDequeue = err
return
}
results[item.Value()] = struct{}{}
Expand Down

0 comments on commit f0d39c1

Please sign in to comment.