chore: update to go 1.18 (#628)

* add make lint to Makefile
This commit is contained in:
Colin Adler
2022-03-28 14:14:40 -05:00
committed by GitHub
parent b33dec9d38
commit be8389fd74
13 changed files with 35 additions and 561 deletions

View File

@ -138,5 +138,7 @@ func getFreePort() (port int, err error) {
}
defer listener.Close()
// This is always a *net.TCPAddr.
// nolint:forcetypeassert
return listener.Addr().(*net.TCPAddr).Port, nil
}

View File

@ -72,6 +72,9 @@ func (p *pgPubsub) Subscribe(event string, listener Listener) (cancel func(), er
}
func (p *pgPubsub) Publish(event string, message []byte) error {
// This is safe because we are calling pq.QuoteLiteral. pg_notify doesn't
// support the first parameter being a prepared statement.
//nolint:gosec
_, err := p.db.ExecContext(context.Background(), `select pg_notify(`+pq.QuoteLiteral(event)+`, $1)`, message)
if err != nil {
return xerrors.Errorf("exec: %w", err)

View File

@ -138,7 +138,9 @@ func (api *api) provisionerJobLogs(rw http.ResponseWriter, r *http.Request, job
// See: https://canjs.com/doc/can-ndjson-stream.html
rw.Header().Set("Content-Type", "application/stream+json")
rw.WriteHeader(http.StatusOK)
rw.(http.Flusher).Flush()
if flusher, ok := rw.(http.Flusher); ok {
flusher.Flush()
}
// The Go stdlib JSON encoder appends a newline character after message write.
encoder := json.NewEncoder(rw)
@ -161,7 +163,9 @@ func (api *api) provisionerJobLogs(rw http.ResponseWriter, r *http.Request, job
if err != nil {
return
}
rw.(http.Flusher).Flush()
if flusher, ok := rw.(http.Flusher); ok {
flusher.Flush()
}
case <-ticker.C:
job, err := api.Database.GetProvisionerJobByID(r.Context(), job.ID)
if err != nil {