✨ Pick file
This commit is contained in:
		
					parent
					
						
							
								53b2e169d0
							
						
					
				
			
			
				commit
				
					
						afb5953ea0
					
				
			
		
					 2 changed files with 11 additions and 1 deletions
				
			
		|  | @ -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
									
								
							
							
						
						
									
										10
									
								
								files/pick.go
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | |||
| package files | ||||
| 
 | ||||
| import "math/rand" | ||||
| 
 | ||||
| func PickRandomFile() string { | ||||
| 	files := GetCandidates() | ||||
| 	idx := rand.Intn(len(files)) | ||||
| 
 | ||||
| 	return files[idx] | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue