Skip to content

Commit

Permalink
feat: add new method to generate random string
Browse files Browse the repository at this point in the history
  • Loading branch information
cybersiddhu committed Sep 26, 2018
1 parent e9fae58 commit 2b0b848
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
28 changes: 28 additions & 0 deletions generate/rand.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package generate

import (
"math/rand"
"time"
)

const (
charSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)

var seedRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))

func stringWithCharset(length int, charset string) string {
var b []byte
for i := 0; i < length; i++ {
b = append(
b,
charset[seedRand.Intn(len(charset))],
)
}
return string(b)
}

// RandString generates a random string of a specific length
func RandString(length int) string {
return stringWithCharset(length, charSet)
}
6 changes: 5 additions & 1 deletion storage/arangodb/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ func (a *arangoSource) UpdateOboGraphInfo(g graph.OboGraph) error {
}

func (a *arangoSource) SaveOrUpdateTerms(g graph.OboGraph) (int, int, error) {
return 0, 0, nil
id, err := a.graphDocId(g)
if err != nil {
return 0, 0, err
}
return 1, 1, nil
}

func (a *arangoSource) SaveNewRelationships(g graph.OboGraph) (int, error) {
Expand Down

0 comments on commit 2b0b848

Please sign in to comment.