Last active
August 29, 2015 14:23
-
-
Save pauladam/f41bb2320b5fdd9180fb to your computer and use it in GitHub Desktop.
Scribe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // tree | |
| // . | |
| // ├── bin | |
| // │ └── scribe | |
| // └── src | |
| // └── scribe | |
| // └── scribe.go | |
| // $ gb build all; bin/scribe | |
| // Jesse | |
| package main | |
| import "os" | |
| import "fmt" | |
| import "time" | |
| import "bufio" | |
| import "math/rand" | |
| func main() { | |
| var names []string | |
| inFile, _ := os.Open("names") | |
| defer inFile.Close() | |
| scanner := bufio.NewScanner(inFile) | |
| scanner.Split(bufio.ScanLines) | |
| for scanner.Scan() { names = append(names, scanner.Text()) } | |
| rand.Seed(time.Now().UTC().UnixNano()) | |
| fmt.Println(names[rand.Intn(len(names))]) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks that all makes sense