diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 40cb654e6e..37adfa198c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -57,7 +57,7 @@ RUN mkdir -p /etc/apt/keyrings \ && echo '{"cgroup-parent":"/actions_job","storage-driver":"vfs"}' >> /etc/docker/daemon.json # install golang and language tooling -ENV GO_VERSION=1.19 +ENV GO_VERSION=1.20 ENV GOPATH=$HOME/go-packages ENV GOROOT=$HOME/go ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2f879b2fb3..515076b4bc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,7 +37,7 @@ jobs: # Install Go! - uses: actions/setup-go@v3 with: - go-version: "~1.19" + go-version: "~1.20" # Check for any typos! - name: Check for typos @@ -55,7 +55,7 @@ jobs: - name: Lint Go uses: golangci/golangci-lint-action@v3.3.1 with: - version: v1.48.0 + version: v1.51.0 - name: Lint shell scripts uses: ludeeus/action-shellcheck@2.0.0 @@ -151,7 +151,7 @@ jobs: - uses: actions/setup-go@v3 with: - go-version: "~1.19" + go-version: "~1.20" - name: Echo Go Cache Paths id: go-cache-paths @@ -250,7 +250,7 @@ jobs: - uses: actions/setup-go@v3 with: - go-version: "~1.19" + go-version: "~1.20" # Sadly the new "set output" syntax (of writing env vars to # $GITHUB_OUTPUT) does not work on both powershell and bash so we use the @@ -333,7 +333,7 @@ jobs: - uses: actions/setup-go@v3 with: - go-version: "~1.19" + go-version: "~1.20" - name: Echo Go Cache Paths id: go-cache-paths @@ -416,7 +416,7 @@ jobs: - uses: actions/setup-go@v3 with: - go-version: "~1.19" + go-version: "~1.20" - name: Echo Go Cache Paths id: go-cache-paths @@ -545,7 +545,7 @@ jobs: - uses: actions/setup-go@v3 with: - go-version: "~1.19" + go-version: "~1.20" - uses: hashicorp/setup-terraform@v2 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 080e6da56b..f33aaa0d9d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -91,7 +91,7 @@ jobs: - uses: actions/setup-go@v3 with: - go-version: "~1.19" + go-version: "~1.20" - name: Cache Node id: cache-node diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index 310b04cb94..15438f2eed 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -38,7 +38,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: "~1.19" + go-version: "~1.20" - name: Go Cache Paths id: go-cache-paths @@ -68,7 +68,7 @@ jobs: - uses: actions/setup-go@v3 with: - go-version: "~1.19" + go-version: "~1.20" - name: Go Cache Paths id: go-cache-paths diff --git a/cli/gitaskpass.go b/cli/gitaskpass.go index 0296ca5266..4c78c47728 100644 --- a/cli/gitaskpass.go +++ b/cli/gitaskpass.go @@ -69,12 +69,12 @@ func gitAskpass() *cobra.Command { if token.Password != "" { if user == "" { - fmt.Fprintln(cmd.OutOrStdout(), token.Username) + _, _ = fmt.Fprintln(cmd.OutOrStdout(), token.Username) } else { - fmt.Fprintln(cmd.OutOrStdout(), token.Password) + _, _ = fmt.Fprintln(cmd.OutOrStdout(), token.Password) } } else { - fmt.Fprintln(cmd.OutOrStdout(), token.Username) + _, _ = fmt.Fprintln(cmd.OutOrStdout(), token.Username) } return nil diff --git a/cli/root_test.go b/cli/root_test.go index 7f5442233b..85863b656a 100644 --- a/cli/root_test.go +++ b/cli/root_test.go @@ -30,8 +30,6 @@ var updateGoldenFiles = flag.Bool("update", false, "update .golden files") //nolint:tparallel,paralleltest // These test sets env vars. func TestCommandHelp(t *testing.T) { - t.Parallel() - commonEnv := map[string]string{ "CODER_CONFIG_DIR": "/tmp/coder-cli-test-config", } diff --git a/coderd/httpmw/ratelimit_test.go b/coderd/httpmw/ratelimit_test.go index e004fb3ed3..4a1c637b58 100644 --- a/coderd/httpmw/ratelimit_test.go +++ b/coderd/httpmw/ratelimit_test.go @@ -24,7 +24,7 @@ import ( func randRemoteAddr() string { var b [4]byte // nolint:gosec - rand.Read(b[:]) + _, _ = rand.Read(b[:]) // nolint:gosec return fmt.Sprintf("%s:%v", net.IP(b[:]).String(), rand.Int31()%(1<<16)) } diff --git a/coderd/rbac/builtin_test.go b/coderd/rbac/builtin_test.go index 220d5df412..92ed3da501 100644 --- a/coderd/rbac/builtin_test.go +++ b/coderd/rbac/builtin_test.go @@ -360,6 +360,7 @@ func TestIsOrgRole(t *testing.T) { // nolint:paralleltest for _, c := range testCases { + c := c t.Run(c.RoleName, func(t *testing.T) { t.Parallel() orgID, ok := rbac.IsOrgRole(c.RoleName) diff --git a/coderd/rbac/regosql/compile.go b/coderd/rbac/regosql/compile.go index 599348b0e4..398cbbf54c 100644 --- a/coderd/rbac/regosql/compile.go +++ b/coderd/rbac/regosql/compile.go @@ -46,9 +46,9 @@ func ConvertRegoAst(cfg ConvertConfig, partial *rego.PartialQueries) (sqltypes.B } if i != 0 { - builder.WriteString("\n") + _, _ = builder.WriteString("\n") } - builder.WriteString(q.String()) + _, _ = builder.WriteString(q.String()) queries = append(queries, converted) } diff --git a/coderd/updatecheck/updatecheck_test.go b/coderd/updatecheck/updatecheck_test.go index 8e1802b27c..3a926473fb 100644 --- a/coderd/updatecheck/updatecheck_test.go +++ b/coderd/updatecheck/updatecheck_test.go @@ -44,7 +44,7 @@ func TestChecker_Notify(t *testing.T) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - w.Write(b) + _, _ = w.Write(b) } })) defer srv.Close() diff --git a/dogfood/Dockerfile b/dogfood/Dockerfile index 52915db09b..cccededb57 100644 --- a/dogfood/Dockerfile +++ b/dogfood/Dockerfile @@ -8,7 +8,7 @@ FROM ubuntu AS go RUN apt-get update && apt-get install --yes curl gcc # Install Go manually, so that we can control the version -ARG GO_VERSION=1.19 +ARG GO_VERSION=1.20 RUN mkdir --parents /usr/local/go # Boring Go is needed to build FIPS-compliant binaries. @@ -210,7 +210,7 @@ RUN systemctl enable \ ARG CLOUD_SQL_PROXY_VERSION=1.26.0 \ DIVE_VERSION=0.10.0 \ DOCKER_GCR_VERSION=2.1.0 \ - GOLANGCI_LINT_VERSION=1.48.0 \ + GOLANGCI_LINT_VERSION=1.51.0 \ GRYPE_VERSION=0.24.0 \ HELM_VERSION=3.8.0 \ KUBE_LINTER_VERSION=0.2.5 \ diff --git a/dogfood/files/etc/apt/preferences.d/docker b/dogfood/files/etc/apt/preferences.d/docker index 1569e645f5..a92c0abb03 100644 --- a/dogfood/files/etc/apt/preferences.d/docker +++ b/dogfood/files/etc/apt/preferences.d/docker @@ -16,5 +16,4 @@ Pin-Priority: 500 # containerd runtime Package: containerd.io Pin: origin download.docker.com -Pin: version 1.5.11-1 Pin-Priority: 500 diff --git a/dogfood/files/usr/share/keyrings/hashicorp.gpg b/dogfood/files/usr/share/keyrings/hashicorp.gpg index 0d3082b232..674dd40c42 100644 Binary files a/dogfood/files/usr/share/keyrings/hashicorp.gpg and b/dogfood/files/usr/share/keyrings/hashicorp.gpg differ diff --git a/dogfood/files/usr/share/keyrings/yarnpkg.gpg b/dogfood/files/usr/share/keyrings/yarnpkg.gpg index 686583c75c..32a096756e 100644 Binary files a/dogfood/files/usr/share/keyrings/yarnpkg.gpg and b/dogfood/files/usr/share/keyrings/yarnpkg.gpg differ diff --git a/enterprise/audit/diff_internal_test.go b/enterprise/audit/diff_internal_test.go index ef3fe9eab0..2dd9300ab4 100644 --- a/enterprise/audit/diff_internal_test.go +++ b/enterprise/audit/diff_internal_test.go @@ -317,7 +317,7 @@ func Test_diff(t *testing.T) { }, exp: audit.Map{ "id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()}, - "template_id": audit.OldNew{Old: "", New: uuid.UUID{2}.String()}, + "template_id": audit.OldNew{Old: "null", New: uuid.UUID{2}.String()}, "created_by": audit.OldNew{Old: "", New: uuid.UUID{4}.String()}, "name": audit.OldNew{Old: "", New: "rust"}, }, @@ -386,7 +386,7 @@ func Test_diff(t *testing.T) { "owner_id": audit.OldNew{Old: "", New: uuid.UUID{2}.String()}, "template_id": audit.OldNew{Old: "", New: uuid.UUID{3}.String()}, "name": audit.OldNew{Old: "", New: "rust workspace"}, - "autostart_schedule": audit.OldNew{Old: "", New: "0 12 * * 1-5"}, + "autostart_schedule": audit.OldNew{Old: "null", New: "0 12 * * 1-5"}, "ttl": audit.OldNew{Old: int64(0), New: int64(8 * time.Hour)}, // XXX: pq still does not support time.Duration }, }, @@ -417,8 +417,8 @@ func runDiffTests(t *testing.T, tests []diffTest) { t.Helper() for _, test := range tests { + test := test typName := reflect.TypeOf(test.left).Name() - t.Run(typName+"/"+test.name, func(t *testing.T) { t.Parallel() require.Equal(t, diff --git a/enterprise/tailnet/coordinator.go b/enterprise/tailnet/coordinator.go index 10605498df..99234d2a00 100644 --- a/enterprise/tailnet/coordinator.go +++ b/enterprise/tailnet/coordinator.go @@ -568,9 +568,9 @@ func (c *haCoordinator) handlePubsubMessage(ctx context.Context, message []byte) func (c *haCoordinator) formatCallMeMaybe(recipient uuid.UUID, nodes []*agpl.Node) ([]byte, error) { buf := bytes.Buffer{} - buf.WriteString(c.id.String() + "|") - buf.WriteString("callmemaybe|") - buf.WriteString(recipient.String() + "|") + _, _ = buf.WriteString(c.id.String() + "|") + _, _ = buf.WriteString("callmemaybe|") + _, _ = buf.WriteString(recipient.String() + "|") err := json.NewEncoder(&buf).Encode(nodes) if err != nil { return nil, xerrors.Errorf("encode node: %w", err) @@ -583,9 +583,9 @@ func (c *haCoordinator) formatCallMeMaybe(recipient uuid.UUID, nodes []*agpl.Nod func (c *haCoordinator) formatAgentHello(id uuid.UUID) ([]byte, error) { buf := bytes.Buffer{} - buf.WriteString(c.id.String() + "|") - buf.WriteString("agenthello|") - buf.WriteString(id.String() + "|") + _, _ = buf.WriteString(c.id.String() + "|") + _, _ = buf.WriteString("agenthello|") + _, _ = buf.WriteString(id.String() + "|") return buf.Bytes(), nil } @@ -594,9 +594,9 @@ func (c *haCoordinator) formatAgentHello(id uuid.UUID) ([]byte, error) { func (c *haCoordinator) formatClientHello(id uuid.UUID) ([]byte, error) { buf := bytes.Buffer{} - buf.WriteString(c.id.String() + "|") - buf.WriteString("clienthello|") - buf.WriteString(id.String() + "|") + _, _ = buf.WriteString(c.id.String() + "|") + _, _ = buf.WriteString("clienthello|") + _, _ = buf.WriteString(id.String() + "|") return buf.Bytes(), nil } @@ -605,9 +605,9 @@ func (c *haCoordinator) formatClientHello(id uuid.UUID) ([]byte, error) { func (c *haCoordinator) formatAgentUpdate(id uuid.UUID, node *agpl.Node) ([]byte, error) { buf := bytes.Buffer{} - buf.WriteString(c.id.String() + "|") - buf.WriteString("agentupdate|") - buf.WriteString(id.String() + "|") + _, _ = buf.WriteString(c.id.String() + "|") + _, _ = buf.WriteString("agentupdate|") + _, _ = buf.WriteString(id.String() + "|") err := json.NewEncoder(&buf).Encode(node) if err != nil { return nil, xerrors.Errorf("encode node: %w", err) @@ -622,8 +622,8 @@ func (c *haCoordinator) ServeHTTPDebug(w http.ResponseWriter, r *http.Request) { c.mutex.RLock() defer c.mutex.RUnlock() - fmt.Fprintln(w, "

high-availability wireguard coordinator debug

") - fmt.Fprintln(w, "

warning: this only provides info from the node that served the request, if there are multiple replicas this data may be incomplete

") + _, _ = fmt.Fprintln(w, "

high-availability wireguard coordinator debug

") + _, _ = fmt.Fprintln(w, "

warning: this only provides info from the node that served the request, if there are multiple replicas this data may be incomplete

") agpl.CoordinatorHTTPDebug(c.agentSockets, c.agentToConnectionSockets, c.agentNameCache)(w, r) } diff --git a/flake.nix b/flake.nix index 881ee583c0..9817c6a6bc 100644 --- a/flake.nix +++ b/flake.nix @@ -24,7 +24,7 @@ getopt git go-migrate - go_1_19 + go_1_20 golangci-lint gopls gotestsum diff --git a/go.mod b/go.mod index dead853462..15e14a9335 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/coder/coder -go 1.19 +go 1.20 // Required until https://github.com/manifoldco/promptui/pull/169 is merged. replace github.com/manifoldco/promptui => github.com/kylecarbs/promptui v0.8.1-0.20201231190244-d8f2159af2b2 diff --git a/provisioner/terraform/safeenv.go b/provisioner/terraform/safeenv.go index 0b3cedd714..4da2fc32cd 100644 --- a/provisioner/terraform/safeenv.go +++ b/provisioner/terraform/safeenv.go @@ -19,7 +19,7 @@ import ( const unsafeEnvCanary = "CODER_DONT_PASS" func init() { - os.Setenv(unsafeEnvCanary, "true") + _ = os.Setenv(unsafeEnvCanary, "true") } func envName(env string) string { diff --git a/scripts/apitypings/main.go b/scripts/apitypings/main.go index 96b4398d0f..23f3e34ab6 100644 --- a/scripts/apitypings/main.go +++ b/scripts/apitypings/main.go @@ -37,7 +37,7 @@ func main() { } // Just cat the output to a file to capture it - fmt.Println(output) + _, _ = fmt.Println(output) } func Generate(directory string) (string, error) { @@ -307,11 +307,11 @@ func (g *Generator) generateOne(m *Maps, obj types.Object) error { var str strings.Builder _, _ = str.WriteString(g.posLine(obj)) if ts.AboveTypeLine != "" { - str.WriteString(ts.AboveTypeLine) - str.WriteRune('\n') + _, _ = str.WriteString(ts.AboveTypeLine) + _, _ = str.WriteRune('\n') } // Use similar output syntax to enums. - str.WriteString(fmt.Sprintf("export type %s = %s\n", obj.Name(), ts.ValueType)) + _, _ = str.WriteString(fmt.Sprintf("export type %s = %s\n", obj.Name(), ts.ValueType)) m.Structs[obj.Name()] = str.String() case *types.Interface: // Interfaces are used as generics. Non-generic interfaces are @@ -353,7 +353,7 @@ func (g *Generator) generateOne(m *Maps, obj types.Object) error { case *types.Func: // Noop default: - fmt.Println(obj.Name()) + _, _ = fmt.Println(obj.Name()) } return nil } @@ -387,7 +387,7 @@ func (g *Generator) buildUnion(obj types.Object, st *types.Union) (string, error allTypes = slice.Unique(allTypes) - s.WriteString(fmt.Sprintf("export type %s = %s\n", obj.Name(), strings.Join(allTypes, " | "))) + _, _ = s.WriteString(fmt.Sprintf("export type %s = %s\n", obj.Name(), strings.Join(allTypes, " | "))) return s.String(), nil } diff --git a/scripts/auditdocgen/main.go b/scripts/auditdocgen/main.go index c51f0de695..378f50e984 100644 --- a/scripts/auditdocgen/main.go +++ b/scripts/auditdocgen/main.go @@ -110,11 +110,11 @@ func updateAuditDoc(doc []byte, auditableResourcesMap AuditableResourcesMap) ([] tableEndIndex := tableStartIndex + j var buffer bytes.Buffer - buffer.Write(doc[:tableStartIndex]) - buffer.WriteByte('\n') + _, _ = buffer.Write(doc[:tableStartIndex]) + _ = buffer.WriteByte('\n') - buffer.WriteString("|Resource||\n") - buffer.WriteString("|--|-----------------|\n") + _, _ = buffer.WriteString("|Resource||\n") + _, _ = buffer.WriteString("|--|-----------------|\n") for _, resourceName := range sortedResourceNames { readableResourceName := resourceName @@ -131,21 +131,21 @@ func updateAuditDoc(doc []byte, auditableResourcesMap AuditableResourcesMap) ([] } auditActionsString := strings.Join(auditActions, ", ") - buffer.WriteString("|" + readableResourceName + "
" + auditActionsString + "|") + _, _ = buffer.WriteString("|" + readableResourceName + "
" + auditActionsString + "|
FieldTracked
") // We must sort the field names to ensure sub-table ordering sortedFieldNames := sortKeys(auditableResourcesMap[resourceName]) for _, fieldName := range sortedFieldNames { isTracked := auditableResourcesMap[resourceName][fieldName] - buffer.WriteString("") + _, _ = buffer.WriteString("") } - buffer.WriteString("
FieldTracked
" + fieldName + "" + strconv.FormatBool(isTracked) + "
" + fieldName + "" + strconv.FormatBool(isTracked) + "
\n") + _, _ = buffer.WriteString("\n") } - buffer.WriteString("\n") - buffer.Write(doc[tableEndIndex:]) + _, _ = buffer.WriteString("\n") + _, _ = buffer.Write(doc[tableEndIndex:]) return buffer.Bytes(), nil } diff --git a/scripts/metricsdocgen/main.go b/scripts/metricsdocgen/main.go index ee69cbf999..09fac07445 100644 --- a/scripts/metricsdocgen/main.go +++ b/scripts/metricsdocgen/main.go @@ -104,21 +104,21 @@ func updatePrometheusDoc(doc []byte, metricFamilies []dto.MetricFamily) ([]byte, tableEndIndex := tableStartIndex + j var buffer bytes.Buffer - buffer.Write(doc[:tableStartIndex]) - buffer.WriteByte('\n') + _, _ = buffer.Write(doc[:tableStartIndex]) + _ = buffer.WriteByte('\n') - buffer.WriteString("| Name | Type | Description | Labels |\n") - buffer.WriteString("| - | - | - | - |\n") + _, _ = buffer.WriteString("| Name | Type | Description | Labels |\n") + _, _ = buffer.WriteString("| - | - | - | - |\n") for _, mf := range metricFamilies { - buffer.WriteString("| ") - buffer.Write([]byte("`" + *mf.Name + "`")) - buffer.WriteString(" | ") - buffer.Write([]byte(strings.ToLower(mf.Type.String()))) - buffer.WriteString(" | ") + _, _ = buffer.WriteString("| ") + _, _ = buffer.Write([]byte("`" + *mf.Name + "`")) + _, _ = buffer.WriteString(" | ") + _, _ = buffer.Write([]byte(strings.ToLower(mf.Type.String()))) + _, _ = buffer.WriteString(" | ") if mf.Help != nil { - buffer.Write([]byte(*mf.Help)) + _, _ = buffer.Write([]byte(*mf.Help)) } - buffer.WriteString(" | ") + _, _ = buffer.WriteString(" | ") labels := map[string]struct{}{} metrics := mf.GetMetric() @@ -129,14 +129,14 @@ func updatePrometheusDoc(doc []byte, metricFamilies []dto.MetricFamily) ([]byte, } if len(labels) > 0 { - buffer.WriteString(strings.Join(sortedKeys(labels), " ")) + _, _ = buffer.WriteString(strings.Join(sortedKeys(labels), " ")) } - buffer.WriteString(" |\n") + _, _ = buffer.WriteString(" |\n") } - buffer.WriteByte('\n') - buffer.Write(doc[tableEndIndex:]) + _ = buffer.WriteByte('\n') + _, _ = buffer.Write(doc[tableEndIndex:]) return buffer.Bytes(), nil } diff --git a/tailnet/coordinator.go b/tailnet/coordinator.go index f1e6d664b8..37d08f12ce 100644 --- a/tailnet/coordinator.go +++ b/tailnet/coordinator.go @@ -456,7 +456,7 @@ func (c *coordinator) ServeHTTPDebug(w http.ResponseWriter, r *http.Request) { c.mutex.RLock() defer c.mutex.RUnlock() - fmt.Fprintln(w, "

in-memory wireguard coordinator debug

") + _, _ = fmt.Fprintln(w, "

in-memory wireguard coordinator debug

") CoordinatorHTTPDebug(c.agentSockets, c.agentToConnectionSockets, c.agentNameCache)(w, r) } @@ -475,8 +475,8 @@ func CoordinatorHTTPDebug( } { - fmt.Fprintf(w, "

# agents: total %d

\n", len(agentSocketsMap)) - fmt.Fprintln(w, "
    ") + _, _ = fmt.Fprintf(w, "

    # agents: total %d

    \n", len(agentSocketsMap)) + _, _ = fmt.Fprintln(w, "
      ") agentSockets := make([]idConn, 0, len(agentSocketsMap)) for id, conn := range agentSocketsMap { @@ -488,7 +488,7 @@ func CoordinatorHTTPDebug( }) for _, agent := range agentSockets { - fmt.Fprintf(w, "
    • %s (%s): created %v ago, write %v ago, overwrites %d
    • \n", + _, _ = fmt.Fprintf(w, "
    • %s (%s): created %v ago, write %v ago, overwrites %d
    • \n", agent.conn.Name, agent.id.String(), now.Sub(time.Unix(agent.conn.Start, 0)).Round(time.Second), @@ -497,7 +497,7 @@ func CoordinatorHTTPDebug( ) if conns := agentToConnectionSocketsMap[agent.id]; len(conns) > 0 { - fmt.Fprintf(w, "

      connections: total %d

      \n", len(conns)) + _, _ = fmt.Fprintf(w, "

      connections: total %d

      \n", len(conns)) connSockets := make([]idConn, 0, len(conns)) for id, conn := range conns { @@ -507,20 +507,20 @@ func CoordinatorHTTPDebug( return a.id.String() < b.id.String() }) - fmt.Fprintln(w, "
        ") + _, _ = fmt.Fprintln(w, "
          ") for _, connSocket := range connSockets { - fmt.Fprintf(w, "
        • %s (%s): created %v ago, write %v ago
        • \n", + _, _ = fmt.Fprintf(w, "
        • %s (%s): created %v ago, write %v ago
        • \n", connSocket.conn.Name, connSocket.id.String(), now.Sub(time.Unix(connSocket.conn.Start, 0)).Round(time.Second), now.Sub(time.Unix(connSocket.conn.LastWrite, 0)).Round(time.Second), ) } - fmt.Fprintln(w, "
        ") + _, _ = fmt.Fprintln(w, "
      ") } } - fmt.Fprintln(w, "
    ") + _, _ = fmt.Fprintln(w, "
") } { @@ -551,8 +551,8 @@ func CoordinatorHTTPDebug( return a.id.String() < b.id.String() }) - fmt.Fprintf(w, "

# missing agents: total %d

\n", len(missingAgents)) - fmt.Fprintln(w, "
    ") + _, _ = fmt.Fprintf(w, "

    # missing agents: total %d

    \n", len(missingAgents)) + _, _ = fmt.Fprintln(w, "
      ") for _, agentConns := range missingAgents { agentName, ok := agentNameCache.Get(agentConns.id) @@ -560,24 +560,24 @@ func CoordinatorHTTPDebug( agentName = "unknown" } - fmt.Fprintf(w, "
    • %s (%s): created ? ago, write ? ago, overwrites ?
    • \n", + _, _ = fmt.Fprintf(w, "
    • %s (%s): created ? ago, write ? ago, overwrites ?
    • \n", agentName, agentConns.id.String(), ) - fmt.Fprintf(w, "

      connections: total %d

      \n", len(agentConns.conns)) - fmt.Fprintln(w, "
        ") + _, _ = fmt.Fprintf(w, "

        connections: total %d

        \n", len(agentConns.conns)) + _, _ = fmt.Fprintln(w, "
          ") for _, agentConn := range agentConns.conns { - fmt.Fprintf(w, "
        • %s (%s): created %v ago, write %v ago
        • \n", + _, _ = fmt.Fprintf(w, "
        • %s (%s): created %v ago, write %v ago
        • \n", agentConn.conn.Name, agentConn.id.String(), now.Sub(time.Unix(agentConn.conn.Start, 0)).Round(time.Second), now.Sub(time.Unix(agentConn.conn.LastWrite, 0)).Round(time.Second), ) } - fmt.Fprintln(w, "
        ") + _, _ = fmt.Fprintln(w, "
      ") } - fmt.Fprintln(w, "
    ") + _, _ = fmt.Fprintln(w, "
") } } } diff --git a/testutil/eventually.go b/testutil/eventually.go index 8b8b3f41ac..e0b0737fe9 100644 --- a/testutil/eventually.go +++ b/testutil/eventually.go @@ -30,11 +30,11 @@ func Eventually(ctx context.Context, t testing.TB, condition func(ctx context.Co msg := "Eventually timed out" if len(msgAndArgs) > 0 { - if m, ok := msgAndArgs[0].(string); ok { - msg = fmt.Sprintf(m, msgAndArgs[1:]...) - } else { + m, ok := msgAndArgs[0].(string) + if !ok { panic("developer error: first argument of msgAndArgs must be a string") } + msg = fmt.Sprintf(m, msgAndArgs[1:]...) } ticker := time.NewTicker(tick)