Pick file

This commit is contained in:
Dan Jones 2023-08-29 15:12:26 -05:00
commit afb5953ea0
2 changed files with 11 additions and 1 deletions

View file

@ -18,7 +18,7 @@ var rootCmd = &cobra.Command{
// Uncomment the following line if your bare application
// has an action associated with it:
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(files.GetCandidates())
fmt.Println(files.PickRandomFile())
},
}

10
files/pick.go Normal file
View file

@ -0,0 +1,10 @@
package files
import "math/rand"
func PickRandomFile() string {
files := GetCandidates()
idx := rand.Intn(len(files))
return files[idx]
}