mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Updated
Former-commit-id: c3352889ee26c1497fae42710f5882bf433a1287 [formerly 6a2773cd3d65d7432e44df1f1f5152efae0730ae] [formerly 9a4189905703e691b3fd77af03f6628f722983f7 [formerly 7e3423c12e
]]
Former-commit-id: 216a85e7fe40818bc67b031b6f03096e34ae3dea [formerly 2742f11d5436272ef272fda6161c40c366962618]
Former-commit-id: c008c65959d8e2cb62048665b69ff716da8b5813
This commit is contained in:
parent
0936562775
commit
6d5b3e45c9
8
db.go
8
db.go
@ -179,12 +179,18 @@ func (p *WikiData) save(newText string) error {
|
||||
}
|
||||
return err
|
||||
})
|
||||
err = db.Update(func(tx *bolt.Tx) error {
|
||||
// Add the new name to the programdata so its not randomly generated
|
||||
if err == nil {
|
||||
err2 := db.Update(func(tx *bolt.Tx) error {
|
||||
b := tx.Bucket([]byte("programdata"))
|
||||
id, _ := b.NextSequence()
|
||||
idInt := int(id)
|
||||
return b.Put(itob(idInt), []byte(p.Title))
|
||||
})
|
||||
if err2 != nil {
|
||||
return fmt.Errorf("could not add to programdata: %s", err)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
16027
static/text/adjectives
Normal file
16027
static/text/adjectives
Normal file
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
||||
ca5be314eff78cb57716e81faadb591fb9dc7f5e
|
3
utils.go
3
utils.go
@ -44,6 +44,7 @@ func randomAdjective() string {
|
||||
|
||||
func randomAlliterateCombo() (combo string) {
|
||||
combo = ""
|
||||
// first determine which names are taken from program data
|
||||
takenNames := []string{}
|
||||
err := db.View(func(tx *bolt.Tx) error {
|
||||
// Assume bucket exists and has keys
|
||||
@ -57,6 +58,7 @@ func randomAlliterateCombo() (combo string) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// generate random alliteration thats not been used
|
||||
for {
|
||||
animal := randomAnimal()
|
||||
adjective := randomAdjective()
|
||||
@ -68,6 +70,7 @@ func randomAlliterateCombo() (combo string) {
|
||||
return
|
||||
}
|
||||
|
||||
// is there a string in a slice?
|
||||
func stringInSlice(s string, strings []string) bool {
|
||||
for _, k := range strings {
|
||||
if s == k {
|
||||
|
Loading…
Reference in New Issue
Block a user