连接客户端 config = clientv3.Config{ Endpoints: []string{"127.0.0.1:2379"}, // 集群列表 DialTimeout: 5 * time.Second, } // 建立一个客户端 if client, err = clientv3.New(config); err != nil { fmt.Println(err) return } put //PUT if putResp, err = kv.Put(context.TODO(), "/prefix/keys/k1", "v1", …
GORM 模型定义 模型实现了Scanner和Valuer接口 模型约定: GORM 使用ID作为主键 如果不默认使用ID作为主键,应该使用标签primaryKey 指定 // 将 `UUID` 设为主键 type Animal struct { ID int64 UUID string `gorm:"primaryKey"` Name string Age int64 } 复合主键 type Product struct { ID string `gorm:"primaryKey"` LanguageCode string `gorm:"primaryKey"` Code …
1.安装flower: pip install flower 1 2. 启动flower 例如启动项目工程下面celery_tasks目录的main.py 异步任务启动函数 flower -A celery_tasks.main --port=5555 1.安装Celery pip install celery 2.编写task from celery import Celery app = Celery('tasks', broker='amqp://guest@localhost//') @app.task def add(x, y): return x + y 3.运行 $ celery -A …
关于切片和slice的内存共享 package main import ( "bufio" "bytes" "errors" "fmt" _errors "github.com/pkg/errors" "os" "reflect" "regexp" "strconv" "strings" "sync" "sync/atomic" "time" ) func main() { /** * @Description: foo boo …