diff --git a/cmd/root.go b/cmd/root.go index 291cbe9..d439493 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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()) }, } diff --git a/files/pick.go b/files/pick.go new file mode 100644 index 0000000..626bc36 --- /dev/null +++ b/files/pick.go @@ -0,0 +1,10 @@ +package files + +import "math/rand" + +func PickRandomFile() string { + files := GetCandidates() + idx := rand.Intn(len(files)) + + return files[idx] +}