From b3294e880f6edae4f5df08812c1ee90dc0a20dac Mon Sep 17 00:00:00 2001 From: nate smith Date: Sun, 1 Sep 2024 15:17:13 -0500 Subject: [PATCH] cleanup --- cmd/contrib/main.go | 3 --- cmd/review/main.go | 5 ++--- cmd/visit/main.go | 7 ++----- request/gitea.go | 2 -- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/cmd/contrib/main.go b/cmd/contrib/main.go index 8b74901..f8b1318 100644 --- a/cmd/contrib/main.go +++ b/cmd/contrib/main.go @@ -3,7 +3,6 @@ package main import ( "errors" "fmt" - "math/rand" "os" "os/user" "path" @@ -71,8 +70,6 @@ func validExec(execPath string) error { } func submit(opts *contribOpts) error { - rand.Seed(time.Now().UTC().UnixNano()) - var cmdName string var category string var shortDesc string diff --git a/cmd/review/main.go b/cmd/review/main.go index f6195f4..749ed56 100644 --- a/cmd/review/main.go +++ b/cmd/review/main.go @@ -153,8 +153,6 @@ func _main() error { r := newReviewer(signupDB, u.Username) - rand.Seed(time.Now().Unix()) - su := models.TownSignup{} signups, err := su.All(signupDB) @@ -437,7 +435,8 @@ func _main() error { if exiterr, ok := err.(*exec.ExitError); ok { // no match or interrupt. who cares switch exiterr.ExitCode() { - case 1: case 130: + case 1: + case 130: return } } diff --git a/cmd/visit/main.go b/cmd/visit/main.go index 2779c5c..789cea2 100644 --- a/cmd/visit/main.go +++ b/cmd/visit/main.go @@ -3,13 +3,11 @@ package main import ( "encoding/json" "fmt" - "io/ioutil" "math/rand" "os" "os/exec" "path/filepath" "strings" - "time" "github.com/AlecAivazis/survey/v2" "github.com/charmbracelet/glamour" @@ -39,7 +37,6 @@ func main() { } func visitRandomUser() error { - rand.Seed(time.Now().UnixNano()) usernames, err := getUsernames() if err != nil { return err @@ -78,7 +75,7 @@ func visitPrompt() error { } func visitUser(username string) error { - files, err := ioutil.ReadDir(filepath.Join("/home", username)) + files, err := os.ReadDir(filepath.Join("/home", username)) if err != nil { return fmt.Errorf("user is not accepting visitors (could not read user's home directory: %w)", err) } @@ -90,7 +87,7 @@ func visitUser(username string) error { path := filepath.Join("/home", username, file.Name()) - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) if err != nil { break } diff --git a/request/gitea.go b/request/gitea.go index fa87c43..3978268 100644 --- a/request/gitea.go +++ b/request/gitea.go @@ -12,7 +12,6 @@ import ( "os/user" "path/filepath" "syscall" - "time" email "git.tilde.town/tildetown/town/email" ) @@ -178,7 +177,6 @@ if you did _not_ request this, please let an admin know. } func genGiteaPassword() string { - rand.Seed(time.Now().UnixNano()) b := make([]byte, 20) for i := range b { b[i] = pwLetters[rand.Intn(len(pwLetters))]