mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-09 10:43:44 +08:00
使用 leveldb 存储用户 token 和聊天记录
This commit is contained in:
20
test/test.go
20
test/test.go
@@ -2,10 +2,26 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"openai/utils"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var data = make(map[string]string)
|
||||
fmt.Println(data["key"] == "")
|
||||
// leveldb 测试
|
||||
db, err := utils.NewLevelDB("data")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
err = db.Put("name", "xiaoming")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
name, err := db.Get("name")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println("name: ", name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user