diff options
author | Andinus <andinus@nand.sh> | 2020-04-06 22:10:56 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-04-06 22:10:56 +0530 |
commit | 69e919cd4e887a606dc1c007c2ce1f36b35477d1 (patch) | |
tree | 5c1525058306491e89714b4aac4dba96654ac4c5 | |
parent | 0121a30a7d0fc67f54dabc56b0b4aa030ac3dac4 (diff) | |
download | grus-69e919cd4e887a606dc1c007c2ce1f36b35477d1.tar.gz |
Add package search
-rw-r--r-- | search/word.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/search/word.go b/search/word.go new file mode 100644 index 0000000..a62a393 --- /dev/null +++ b/search/word.go @@ -0,0 +1,23 @@ +package search + +import ( + "tildegit.org/andinus/grus/storage" +) + +// Word will search for unjumbled words in database, given sorted word. +func Word(sorted string, db *storage.DB) (out string, err error) { + db.Mu.RLock() + defer db.Mu.RUnlock() + + stmt, err := db.Conn.Prepare("SELECT word FROM words WHERE sorted = ?") + if err != nil { + return + } + defer stmt.Close() + + err = stmt.QueryRow(sorted).Scan(&out) + if err != nil { + return + } + return +} |