Skip to content

Commit

Permalink
Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Aug 1, 2023
1 parent 006a803 commit cb7f0f0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
11 changes: 8 additions & 3 deletions pkg/commands/oscommands/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package oscommands
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
)
Expand Down Expand Up @@ -106,7 +105,7 @@ func CopyDir(src string, dst string) (err error) {
return //nolint: nakedret
}

entries, err := ioutil.ReadDir(src)
entries, err := os.ReadDir(src)
if err != nil {
return //nolint: nakedret
}
Expand All @@ -121,8 +120,14 @@ func CopyDir(src string, dst string) (err error) {
return //nolint: nakedret
}
} else {
var info os.FileInfo
info, err = entry.Info()
if err != nil {
return //nolint: nakedret
}

// Skip symlinks.
if entry.Mode()&os.ModeSymlink != 0 {
if info.Mode()&os.ModeSymlink != 0 {
continue
}

Expand Down
5 changes: 2 additions & 3 deletions pkg/config/config_linux.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package config

import (
"io/ioutil"
"os"
"strings"
)

func isWSL() bool {
data, err := ioutil.ReadFile("/proc/sys/kernel/osrelease")
data, err := os.ReadFile("/proc/sys/kernel/osrelease")
return err == nil && strings.Contains(string(data), "microsoft")
}

func isContainer() bool {
data, err := ioutil.ReadFile("/proc/1/cgroup")
data, err := os.ReadFile("/proc/1/cgroup")

if strings.Contains(string(data), "docker") ||
strings.Contains(string(data), "/lxc/") ||
Expand Down
6 changes: 3 additions & 3 deletions pkg/gui/controllers/workspace_reset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func getExplodeImage(width int, height int, frame int, max int) string {
var buf bytes.Buffer

// Initialize RNG seed
rand.Seed(time.Now().UnixNano())
random := rand.New(rand.NewSource(time.Now().UnixNano()))

// calculate the center of explosion
centerX, centerY := width/2, height/2
Expand Down Expand Up @@ -223,9 +223,9 @@ func getExplodeImage(width int, height int, frame int, max int) string {
// if distance is less than radius and greater than innerRadius, draw explosion char
if distance <= radius && distance >= innerRadius {
// Make placement random and less likely as explosion progresses
if rand.Float64() > progress {
if random.Float64() > progress {
// Pick a random explosion char
char := explosionChars[rand.Intn(len(explosionChars))]
char := explosionChars[random.Intn(len(explosionChars))]
buf.WriteRune(char)
} else {
buf.WriteRune(' ')
Expand Down
3 changes: 1 addition & 2 deletions pkg/integration/clients/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"bytes"
"errors"
"io"
"io/ioutil"
"os"
"os/exec"
"testing"
Expand Down Expand Up @@ -82,7 +81,7 @@ func runCmdHeadless(cmd *exec.Cmd) error {
return err
}

_, _ = io.Copy(ioutil.Discard, f)
_, _ = io.Copy(io.Discard, f)

if cmd.Wait() != nil {
// return an error with the stderr output
Expand Down
3 changes: 1 addition & 2 deletions pkg/integration/components/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package components

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -222,7 +221,7 @@ func findOrCreateDir(path string) {

func deleteAndRecreateEmptyDir(path string) {
// remove contents of integration test directory
dir, err := ioutil.ReadDir(path)
dir, err := os.ReadDir(path)
if err != nil {
if os.IsNotExist(err) {
err = os.Mkdir(path, 0o777)
Expand Down
13 changes: 6 additions & 7 deletions pkg/integration/tests/test_list_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"fmt"
"go/format"
"io/fs"
"io/ioutil"
"os"
"strings"

Expand All @@ -26,19 +25,19 @@ func main() {
if err != nil {
panic(err)
}
if err := ioutil.WriteFile("test_list.go", formattedCode, 0o644); err != nil {
if err := os.WriteFile("test_list.go", formattedCode, 0o644); err != nil {
panic(err)
}
}

func generateCode() []byte {
// traverse parent directory to get all subling directories
directories, err := ioutil.ReadDir("../tests")
directories, err := os.ReadDir("../tests")
if err != nil {
panic(err)
}

directories = lo.Filter(directories, func(file os.FileInfo, _ int) bool {
directories = lo.Filter(directories, func(file fs.DirEntry, _ int) bool {
// 'shared' is a special folder containing shared test code so we
// ignore it here
return file.IsDir() && file.Name() != "shared"
Expand All @@ -62,8 +61,8 @@ func generateCode() []byte {
return buf.Bytes()
}

func appendDirTests(dir fs.FileInfo, buf *bytes.Buffer) {
files, err := ioutil.ReadDir(fmt.Sprintf("../tests/%s", dir.Name()))
func appendDirTests(dir fs.DirEntry, buf *bytes.Buffer) {
files, err := os.ReadDir(fmt.Sprintf("../tests/%s", dir.Name()))
if err != nil {
panic(err)
}
Expand All @@ -77,7 +76,7 @@ func appendDirTests(dir fs.FileInfo, buf *bytes.Buffer) {
strings.TrimSuffix(file.Name(), ".go"),
)

fileContents, err := ioutil.ReadFile(fmt.Sprintf("../tests/%s/%s", dir.Name(), file.Name()))
fileContents, err := os.ReadFile(fmt.Sprintf("../tests/%s/%s", dir.Name(), file.Name()))
if err != nil {
panic(err)
}
Expand Down

0 comments on commit cb7f0f0

Please sign in to comment.