Skip to content

Commit

Permalink
lint: minor warns
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Aug 7, 2022
1 parent 7b2780c commit 1cc5c21
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"math/rand"
"net/http"
"os"
Expand Down Expand Up @@ -46,7 +46,7 @@ func Test_main(t *testing.T) {
require.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, 200, resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
assert.NoError(t, err)
assert.Equal(t, "pong", string(body))
}
Expand Down
4 changes: 2 additions & 2 deletions app/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"time"

"github.com/didip/tollbooth/v6"
"github.com/didip/tollbooth/v7"
"github.com/didip/tollbooth_chi"
"github.com/go-chi/chi/v5"
log "github.com/go-pkgz/lgr"
Expand Down Expand Up @@ -103,7 +103,7 @@ func (s *Rest) taskPostCtrl(w http.ResponseWriter, r *http.Request) {
s.execTask(w, r, req.Secret, req.Task, req.Async)
}

func (s *Rest) execTask(w http.ResponseWriter, r *http.Request, secret string, taskName string, isAsync bool) {
func (s *Rest) execTask(w http.ResponseWriter, r *http.Request, secret, taskName string, isAsync bool) {
if subtle.ConstantTimeCompare([]byte(secret), []byte(s.SecretKey)) != 1 {
http.Error(w, "rejected", http.StatusForbidden)
return
Expand Down
5 changes: 2 additions & 3 deletions app/task/shell_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -99,7 +98,7 @@ func (s *ShellRunner) prepBatch(cmd string) (batchFile string, err error) {
var script []string
script = append(script, "#!bin/sh")
script = append(script, strings.Split(cmd, "\n")...)
fh, e := ioutil.TempFile("/tmp", "updater")
fh, e := os.CreateTemp("/tmp", "updater")
if e != nil {
return "", errors.Wrap(e, "failed to prep batch")
}
Expand All @@ -108,7 +107,7 @@ func (s *ShellRunner) prepBatch(cmd string) (batchFile string, err error) {
fname := fh.Name()
errs = multierror.Append(errs, fh.Sync())
errs = multierror.Append(errs, fh.Close())
errs = multierror.Append(errs, os.Chmod(fname, 0755)) //nolint
errs = multierror.Append(errs, os.Chmod(fname, 0755)) // nolint
if errs.ErrorOrNil() != nil {
log.Printf("[WARN] can't properly close %s, %v", fname, errs.Error())
}
Expand Down

0 comments on commit 1cc5c21

Please sign in to comment.