Skip to content

Commit

Permalink
chore: update to go 1.20 (coder#5968)
Browse files Browse the repository at this point in the history
Co-authored-by: Colin Adler <[email protected]>
  • Loading branch information
kylecarbs and coadler authored Feb 2, 2023
1 parent 4df1031 commit 026b1cd
Show file tree
Hide file tree
Showing 24 changed files with 91 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -55,7 +55,7 @@ jobs:
- name: Lint Go
uses: golangci/[email protected]
with:
version: v1.48.0
version: v1.51.0

- name: Lint shell scripts
uses: ludeeus/[email protected]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cli/gitaskpass.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions cli/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down
2 changes: 1 addition & 1 deletion coderd/httpmw/ratelimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
1 change: 1 addition & 0 deletions coderd/rbac/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions coderd/rbac/regosql/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion coderd/updatecheck/updatecheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions dogfood/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 \
Expand Down
1 change: 0 additions & 1 deletion dogfood/files/etc/apt/preferences.d/docker
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified dogfood/files/usr/share/keyrings/hashicorp.gpg
Binary file not shown.
Binary file modified dogfood/files/usr/share/keyrings/yarnpkg.gpg
Binary file not shown.
6 changes: 3 additions & 3 deletions enterprise/audit/diff_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
Expand Down Expand Up @@ -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
},
},
Expand Down Expand Up @@ -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,
Expand Down
28 changes: 14 additions & 14 deletions enterprise/tailnet/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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)
Expand All @@ -622,8 +622,8 @@ func (c *haCoordinator) ServeHTTPDebug(w http.ResponseWriter, r *http.Request) {
c.mutex.RLock()
defer c.mutex.RUnlock()

fmt.Fprintln(w, "<h1>high-availability wireguard coordinator debug</h1>")
fmt.Fprintln(w, "<h4 style=\"margin-top:-25px\">warning: this only provides info from the node that served the request, if there are multiple replicas this data may be incomplete</h4>")
_, _ = fmt.Fprintln(w, "<h1>high-availability wireguard coordinator debug</h1>")
_, _ = fmt.Fprintln(w, "<h4 style=\"margin-top:-25px\">warning: this only provides info from the node that served the request, if there are multiple replicas this data may be incomplete</h4>")

agpl.CoordinatorHTTPDebug(c.agentSockets, c.agentToConnectionSockets, c.agentNameCache)(w, r)
}
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
getopt
git
go-migrate
go_1_19
go_1_20
golangci-lint
gopls
gotestsum
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion provisioner/terraform/safeenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions scripts/apitypings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
18 changes: 9 additions & 9 deletions scripts/auditdocgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("|<b>Resource<b>||\n")
buffer.WriteString("|--|-----------------|\n")
_, _ = buffer.WriteString("|<b>Resource<b>||\n")
_, _ = buffer.WriteString("|--|-----------------|\n")

for _, resourceName := range sortedResourceNames {
readableResourceName := resourceName
Expand All @@ -131,21 +131,21 @@ func updateAuditDoc(doc []byte, auditableResourcesMap AuditableResourcesMap) ([]
}
auditActionsString := strings.Join(auditActions, ", ")

buffer.WriteString("|" + readableResourceName + "<br><i>" + auditActionsString + "</i>|<table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody>")
_, _ = buffer.WriteString("|" + readableResourceName + "<br><i>" + auditActionsString + "</i>|<table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody>")

// 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("<tr><td>" + fieldName + "</td><td>" + strconv.FormatBool(isTracked) + "</td></tr>")
_, _ = buffer.WriteString("<tr><td>" + fieldName + "</td><td>" + strconv.FormatBool(isTracked) + "</td></tr>")
}

buffer.WriteString("</tbody></table>\n")
_, _ = buffer.WriteString("</tbody></table>\n")
}

buffer.WriteString("\n")
buffer.Write(doc[tableEndIndex:])
_, _ = buffer.WriteString("\n")
_, _ = buffer.Write(doc[tableEndIndex:])
return buffer.Bytes(), nil
}

Expand Down
Loading

0 comments on commit 026b1cd

Please sign in to comment.