Skip to content

Instantly share code, notes, and snippets.

@pauladam
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save pauladam/f41bb2320b5fdd9180fb to your computer and use it in GitHub Desktop.

Select an option

Save pauladam/f41bb2320b5fdd9180fb to your computer and use it in GitHub Desktop.
Scribe
// 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))])
}
@pauladam
Copy link
Copy Markdown
Author

thanks that all makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment