业务背景
有这样的业务场景, 线上一个表 tablea
, 先生环境还有一个镜像表 tablea_mirror
, 你需要当 请求中有一些 tag
标识的时候,访问 tablea_mirror
表
先安装 sqlite
https://wangxiaoming.blog.csdn.net/article/details/121884736
代码
可以使用 DefaultTableNameHandler
来实现加前缀或者后缀功能。
import (
"code.byted.org/gopkg/gorm"
"context"
)
type dbStagingPos