From 026b1cd2a470312adc915a341f60414b07146d2e Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Thu, 2 Feb 2023 12:36:27 -0600 Subject: [PATCH] chore: update to go 1.20 (#5968) Co-authored-by: Colin Adler --- .devcontainer/Dockerfile | 2 +- .github/workflows/ci.yaml | 14 ++++---- .github/workflows/release.yaml | 2 +- .github/workflows/security.yaml | 4 +-- cli/gitaskpass.go | 6 ++-- cli/root_test.go | 2 -- coderd/httpmw/ratelimit_test.go | 2 +- coderd/rbac/builtin_test.go | 1 + coderd/rbac/regosql/compile.go | 4 +-- coderd/updatecheck/updatecheck_test.go | 2 +- dogfood/Dockerfile | 4 +-- dogfood/files/etc/apt/preferences.d/docker | 1 - .../files/usr/share/keyrings/hashicorp.gpg | Bin 2301 -> 2879 bytes dogfood/files/usr/share/keyrings/yarnpkg.gpg | Bin 11460 -> 10365 bytes enterprise/audit/diff_internal_test.go | 6 ++-- enterprise/tailnet/coordinator.go | 28 +++++++-------- flake.nix | 2 +- go.mod | 2 +- provisioner/terraform/safeenv.go | 2 +- scripts/apitypings/main.go | 12 +++---- scripts/auditdocgen/main.go | 18 +++++----- scripts/metricsdocgen/main.go | 30 ++++++++-------- tailnet/coordinator.go | 34 +++++++++--------- testutil/eventually.go | 6 ++-- 24 files changed, 91 insertions(+), 93 deletions(-) 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 0d3082b232e2b31f9becdaf3b5f73ace4516d39e..674dd40c4219e7f397ea58978a945ccf952b79ff 100644 GIT binary patch delta 2798 zcmaLXcRbV&1HkcfHizSo9T8HYG9r7Om7MHR>U8!xBl}CTw@`LSM7BF*oos&M?3qn= zgsgKsfZ+uACLKGYbcbm-O|^&o^ujhq__rCo#gFj*2C$ZBF95Ko>cIb*d;! z6bsNA+ji`E~1W40pIy*RwrnKZ^bU$CaO))Woqj$(Ia2HRbyr@ zdbP)}&|~k|e@^}F877kWPGO7JfNApgR=a`%2UBPCPO%49SzlT#Gw2@t5S` z!y#(BPu8RaKbt}Jo?EmP4p+t`9fv`fv5W?T@d+!XqeZ*FH>RG=2Rcdu(ji>&`36?O zvAo5#<(OQ4#(BSi`Uy_?FF_MEHW1w=d}zCRC5bo1Wf)~`L60*4dH49^+H^RR~trY!f)Wano<%o3R|0PT*< zpQ%PmQo*LIzwNqM{4eI?$wB>hw%YdnA6bsd*(_4Nbq)`!zTh{J(k||h6U1&Wak&T3 zA-5z*uLvWmC-BlC^kexYZ{ zq7oagvRlG>(e#mTorD~WY;KY#r=~`cOoM2sq5t+dKPc!s#ppuPm|Anc5B?7E5d8su zFnbxPTef+|jF=O#K6))9p zv}a*w3#oA{m6#T)d+31shjUbKlyNjA!?hPY!BVA;>N)z#Amf4GE?=fA7)r$8E~aDZ z;z!MzKY$WGhfsx;GL@0Ix%7Y7Z8~Om$-RKG%JMFr=FhJ-5=bShr{D8Gj?<44{amPF z;~^_;%~3mCQp;?`ru{=D&Ri^^zHy=+NdSfree)IDl15cu<&sIk&)fn%s44r{*&nT|rsL9Xdv<_Zl&G(@cr$3YffOF4T z)V@U#&2fM~H={lqJ>hDi4~Q_~34c5erkz@g@S?dr?4Ul?{D5r&M^8m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m%i^uxTh4KMt-J p?E=WNkkS^P+CH$<;CyQ#21-QF5guzIV2OWo2E)Px2x`Qv2Y&U*Llyu4 diff --git a/dogfood/files/usr/share/keyrings/yarnpkg.gpg b/dogfood/files/usr/share/keyrings/yarnpkg.gpg index 686583c75c24a1f36f0e8023a06845ed950be17b..32a096756e31710f2790d891a9ad1e6ae262e66e 100644 GIT binary patch delta 1090 zcmV-I1ikyjS^ZG3vmKLYC?g7E&wGRg2@OWk^Rp)+D*}IXu@C=D<|%&aCPT2Z1w#87 zCNx%_tB=JM!G9n(Y9h&A$&A5g(sW4D+>)x=8qO(H_ZA5a2yk(P^h6->A(T$UuxXuQ z`}1+;9y7x3D}dE7h~uWhCC4Pbhj@@Rsi+|~@VT6v9t-^xWlj=W?Vj3?W1v}B7fRKY zKu>fyh5dhiqh%TDj$m?Yx~(2?mJ2F$XE|IauVGe+?xYvIxKz>%*2tY{|Mz$e1uCs| zz57gRYs;|4{9Cs;zq4erH+9^pP0@ z89YKaT&2?*=0I%=SY5rpU-KlA#{YFj+~&#XNOQEoq6`Z9Y@JxkBu-;Mmxr7g>R*Br z-vfV=Lt8^soAqz}Ffx}nz6E^OJQs{yFf1JBAK(uVRvUedep=IXDLuhlT}B0t(k-qx zgUdNm2A#_AA4CYuw)#i3Q%LTl)uk64b4OlY`mrM8og$RK@G5TAYn5R_<7Hhs2xON~ zgZM95wyZhe^TXnl9s}SV^2Qny1UBnDYUs8gY<4(yuiMG zf1u~A#X?iwN8m`Tr-E%{ZuT5_ktDjf-L^6YAiueNq7zfi9A~-#=bh@^$Vo$i?sNeM zg-4Csba5fSE2ccS+9ze3NPBTcLhv2M&X*pgFZi|$my0o=tb~Ns={N7WwOAX+V=+n~ zS|!TSKKP=C4@%8695Za}ILSx$-%bdG|CIKY97b|* zB+e;2Hy39U;%>Ab*i3z0mC=#EW0Cd@zRec~aFbGWrR8N+l+ozgg#z38u({3l)XuJP z{_YP0dKJ^qR#IWsrPVI>&5I^3gGq0}doq6ux*>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/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)