package main import ( "bytes" _ "embed" "encoding/gob" "fmt" "math/rand" ) //go:embed words5.gob var b []byte func main() { dec := gob.NewDecoder(bytes.NewReader(b)) words := []string{} if err := dec.Decode(&words); err != nil { panic(err) } numWords := len(words) fmt.Println(words[rand.Int()%numWords]) }