From afb5953ea0490f9f3526646b44e0aa6409d79154 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Tue, 29 Aug 2023 15:12:26 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Pick=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/root.go | 2 +- files/pick.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 files/pick.go 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] +}