Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix lint workflow #330

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions cmd/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ package cmd

import (
"fmt"
"io/ioutil"
"io/fs"
"os"
"path/filepath"
"runtime"
"sort"
Expand Down Expand Up @@ -221,13 +222,30 @@ func sortParams(params []string) []string {
return sorted
}

func readDir(dirname string) ([]fs.FileInfo, error) {
entries, err := os.ReadDir(dirname)
if err != nil {
return nil, err
}
infos := make([]fs.FileInfo, 0, len(entries))
for _, entry := range entries {
info, err := entry.Info()
if err != nil {
return infos, err
}
infos = append(infos, info)
}

return infos, nil
}

func params(cmd *cobra.Command, args []string) {
if debug {
viper.Debug()
}
var modelDirs []string
if dir != "" {
fi, err := ioutil.ReadDir(dir)
fi, err := readDir(dir)
if err != nil {
log.Fatal(err)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ func NewRootCmd() *cobra.Command {
}

// Set random for application
rand.Seed(time.Now().UnixNano())
// TODO: Remove Seed call once minimum Go is 1.20 (SA1019).
rand.Seed(time.Now().UnixNano()) //nolint:staticcheck

cobra.OnInitialize(initConfig)

Expand Down