mirror of
https://gitee.com/johng/gf
synced 2026-06-08 10:37:44 +08:00
Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b040654574 | |||
| 505fc25a64 | |||
| 83ba887df7 | |||
| 911f1cb1de | |||
| 1b7aea0ced | |||
| db5eed17b1 | |||
| 1ffb510a77 | |||
| f039393b2b | |||
| 00ba053ce6 | |||
| dcf1f19ff7 | |||
| 06826750ed | |||
| e0a2645f4a | |||
| 509fdf45c6 | |||
| 1e7d897b66 | |||
| 6df0a9ca66 | |||
| 1c12f3a30d | |||
| 3a9e0e34ca | |||
| 8669512f42 | |||
| 313d9d138f | |||
| 040118b7c6 | |||
| b3f48212f1 | |||
| cade0775e8 | |||
| 164aad48c3 | |||
| 04756d05a7 | |||
| 409041b965 | |||
| 11f7187367 | |||
| 4feda4c395 | |||
| a8713da97f | |||
| 199737cd0f | |||
| 3a8f246569 | |||
| 607f079b23 | |||
| cab6b89446 | |||
| 6ed3038312 | |||
| 9b48da459e | |||
| fbd266fad0 | |||
| 240dadff92 | |||
| 290f4a3e65 | |||
| 97fcd9d726 | |||
| df15d70466 | |||
| 680ae8616b | |||
| 4feb8219fa | |||
| 509cc47d3f | |||
| 849b104c31 | |||
| ce3ef13e6a | |||
| c8a73f8c25 | |||
| b71ee13ccd | |||
| a347cdc30e | |||
| 39a88ef650 | |||
| 8b156e25c4 | |||
| eb0c4b3824 | |||
| 56ef0c0735 | |||
| a1a9465e52 |
8
.github/workflows/ci-main.sh
vendored
8
.github/workflows/ci-main.sh
vendored
@ -70,6 +70,14 @@ for file in `find . -name go.mod`; do
|
||||
fi
|
||||
fi
|
||||
|
||||
# package otelmetric needs golang >= v1.20
|
||||
if [ "otelmetric" = $(basename $dirpath) ]; then
|
||||
if ! go version|grep -qE "go1.[2-9][0-9]"; then
|
||||
echo "ignore otelmetric as go version: $(go version)"
|
||||
continue 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cd $dirpath
|
||||
go mod tidy
|
||||
go build ./...
|
||||
|
||||
31
.github/workflows/ci-main.yml
vendored
31
.github/workflows/ci-main.yml
vendored
@ -66,6 +66,15 @@ jobs:
|
||||
ports:
|
||||
- 3306:3306
|
||||
|
||||
# MariaDb backend server.
|
||||
mariadb:
|
||||
image: loads/mariadb:10.4
|
||||
env:
|
||||
MARIADB_DATABASE: test
|
||||
MARIADB_ROOT_PASSWORD: 12345678
|
||||
ports:
|
||||
- 3307:3306
|
||||
|
||||
# PostgreSQL backend server.
|
||||
# docker run -d --name postgres \
|
||||
# -p 5432:5432 \
|
||||
@ -176,7 +185,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [ "1.18", "1.19", "1.20", "1.21" ]
|
||||
go-version: [ "1.18", "1.19", "1.20", "1.21", "1.22" ]
|
||||
goarch: [ "386", "amd64" ]
|
||||
|
||||
steps:
|
||||
@ -190,19 +199,19 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Start Apollo Containers
|
||||
run: docker-compose -f ".github/workflows/apollo/docker-compose.yml" up -d --build
|
||||
run: docker compose -f ".github/workflows/apollo/docker-compose.yml" up -d --build
|
||||
|
||||
- name: Start Nacos Containers
|
||||
run: docker-compose -f ".github/workflows/nacos/docker-compose.yml" up -d --build
|
||||
run: docker compose -f ".github/workflows/nacos/docker-compose.yml" up -d --build
|
||||
|
||||
- name: Start Redis Cluster Containers
|
||||
run: docker-compose -f ".github/workflows/redis/docker-compose.yml" up -d --build
|
||||
run: docker compose -f ".github/workflows/redis/docker-compose.yml" up -d --build
|
||||
|
||||
- name: Start Consul Containers
|
||||
run: docker-compose -f ".github/workflows/consul/docker-compose.yml" up -d --build
|
||||
run: docker compose -f ".github/workflows/consul/docker-compose.yml" up -d --build
|
||||
|
||||
- name: Setup Golang ${{ matrix.go-version }}
|
||||
uses: actions/setup-go@v4
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
cache-dependency-path: '**/go.sum'
|
||||
@ -219,19 +228,19 @@ jobs:
|
||||
run: bash .github/workflows/ci-main.sh coverage
|
||||
|
||||
- name: Stop Redis Cluster Containers
|
||||
run: docker-compose -f ".github/workflows/redis/docker-compose.yml" down
|
||||
run: docker compose -f ".github/workflows/redis/docker-compose.yml" down
|
||||
|
||||
- name: Stop Apollo Containers
|
||||
run: docker-compose -f ".github/workflows/apollo/docker-compose.yml" down
|
||||
run: docker compose -f ".github/workflows/apollo/docker-compose.yml" down
|
||||
|
||||
- name: Stop Nacos Containers
|
||||
run: docker-compose -f ".github/workflows/nacos/docker-compose.yml" down
|
||||
run: docker compose -f ".github/workflows/nacos/docker-compose.yml" down
|
||||
|
||||
- name: Stop Consul Containers
|
||||
run: docker-compose -f ".github/workflows/consul/docker-compose.yml" down
|
||||
run: docker compose -f ".github/workflows/consul/docker-compose.yml" down
|
||||
|
||||
- name: Report Coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
uses: codecov/codecov-action@v4
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
|
||||
with:
|
||||
flags: go-${{ matrix.go-version }}-${{ matrix.goarch }}
|
||||
|
||||
4
.github/workflows/ci-sub.yml
vendored
4
.github/workflows/ci-sub.yml
vendored
@ -37,7 +37,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [ "1.18", "1.19", "1.20", "1.21" ]
|
||||
go-version: [ "1.18", "1.19", "1.20", "1.22" ]
|
||||
goarch: [ "386", "amd64" ]
|
||||
|
||||
steps:
|
||||
@ -53,7 +53,7 @@ jobs:
|
||||
uses: medyagh/setup-minikube@master
|
||||
|
||||
- name: Setup Golang ${{ matrix.go-version }}
|
||||
uses: actions/setup-go@v4
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
cache-dependency-path: '**/go.sum'
|
||||
|
||||
38
.github/workflows/doc-build.yml
vendored
Normal file
38
.github/workflows/doc-build.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
name: Deploy to GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'doc-build'
|
||||
schedule:
|
||||
- cron: '0 15 * * *'
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy to GitHub Pages
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: doc-build
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
cache: npm
|
||||
- name: Set Up Golang Environment
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 1.20.4
|
||||
cache: false
|
||||
- name: download goframe docs
|
||||
run: ./download.sh
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Build website
|
||||
run: npm run build
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./build
|
||||
cname: pages.goframe.org
|
||||
8
.github/workflows/golangci-lint.yml
vendored
8
.github/workflows/golangci-lint.yml
vendored
@ -36,19 +36,19 @@ jobs:
|
||||
golangci:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [ '1.18','1.19','1.20','1.21.4' ]
|
||||
go-version: [ '1.18','1.19','1.20','1.21.4','1.22' ]
|
||||
name: golangci-lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Golang ${{ matrix.go-version }}
|
||||
uses: actions/setup-go@v4
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
uses: golangci/golangci-lint-action@v4
|
||||
with:
|
||||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||
version: v1.52.2
|
||||
version: v1.56.2
|
||||
args: --timeout 3m0s
|
||||
|
||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set Up Golang Environment
|
||||
uses: actions/setup-go@v4
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.20.8
|
||||
|
||||
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@ -16,4 +16,9 @@ cmd/gf/gf
|
||||
temp/
|
||||
go.work
|
||||
go.work.sum
|
||||
!cmd/gf/go.work
|
||||
!cmd/gf/go.work
|
||||
|
||||
# Ignore for docs
|
||||
node_modules
|
||||
.docusaurus
|
||||
output
|
||||
|
||||
@ -262,7 +262,7 @@ linters-settings:
|
||||
# Select the Go version to target.
|
||||
# Default: "1.13"
|
||||
# Deprecated: use the global `run.go` instead.
|
||||
go: "1.15"
|
||||
go: "1.20"
|
||||
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
|
||||
# Default: ["*"]
|
||||
checks: [ "all","-SA1019","-SA4015","-SA1029","-SA1016","-SA9003","-SA4006","-SA6003" ]
|
||||
|
||||
@ -62,7 +62,8 @@ golang version >= 1.18
|
||||
# Documentation
|
||||
|
||||
- Chinese Official Site(中文官网): [https://goframe.org](https://goframe.org/display/gf)
|
||||
- Offline Document(中文离线文档): [https://github.com/gogf/goframe.org-pdf](https://github.com/gogf/goframe.org-pdf)
|
||||
- Chinese Pages Document(中文镜像文档): [https://pages.goframe.org](https://pages.goframe.org)
|
||||
- Chinese Offline Document(中文离线文档): [https://github.com/gogf/goframe.org-pdf](https://github.com/gogf/goframe.org-pdf)
|
||||
- GoDoc API: [https://pkg.go.dev/github.com/gogf/gf/v2](https://pkg.go.dev/github.com/gogf/gf/v2)
|
||||
|
||||
# License
|
||||
|
||||
@ -3,13 +3,13 @@ module github.com/gogf/gf/cmd/gf/v2
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.6.3
|
||||
github.com/gogf/gf/contrib/drivers/mssql/v2 v2.6.3
|
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.6.3
|
||||
github.com/gogf/gf/contrib/drivers/oracle/v2 v2.6.3
|
||||
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.6.3
|
||||
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.7.0
|
||||
github.com/gogf/gf/contrib/drivers/mssql/v2 v2.7.0
|
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.7.0
|
||||
github.com/gogf/gf/contrib/drivers/oracle/v2 v2.7.0
|
||||
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.7.0
|
||||
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.7.0
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
golang.org/x/mod v0.9.0
|
||||
|
||||
@ -25,6 +25,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
// Init .
|
||||
Init = cInit{}
|
||||
)
|
||||
|
||||
@ -64,14 +65,13 @@ type cInitInput struct {
|
||||
Name string `name:"NAME" arg:"true" v:"required" brief:"{cInitNameBrief}"`
|
||||
Mono bool `name:"mono" short:"m" brief:"initialize a mono-repo instead a single-repo" orphan:"true"`
|
||||
Update bool `name:"update" short:"u" brief:"update to the latest goframe version" orphan:"true"`
|
||||
Module string `name:"module" short:"g" brief:"custom go module"`
|
||||
}
|
||||
|
||||
type cInitOutput struct{}
|
||||
|
||||
func (c cInit) Index(ctx context.Context, in cInitInput) (out *cInitOutput, err error) {
|
||||
var (
|
||||
overwrote = false
|
||||
)
|
||||
var overwrote = false
|
||||
if !gfile.IsEmpty(in.Name) && !allyes.Check() {
|
||||
s := gcmd.Scanf(`the folder "%s" is not empty, files might be overwrote, continue? [y/n]: `, in.Name)
|
||||
if strings.EqualFold(s, "n") {
|
||||
@ -105,7 +105,7 @@ func (c cInit) Index(ctx context.Context, in cInitInput) (out *cInitOutput, err
|
||||
err = gfile.ReadLines(gitignoreFile, func(line string) error {
|
||||
// Add only hidden files or directories
|
||||
// If other directories are added, it may cause the entire directory to be ignored
|
||||
// such as 'main' in the .gitignore file, but the path is 'D:\main\my-project'
|
||||
// such as 'main' in the .gitignore file, but the path is ' D:\main\my-project '
|
||||
if line != "" && strings.HasPrefix(line, ".") {
|
||||
ignoreFiles = append(ignoreFiles, line)
|
||||
}
|
||||
@ -118,6 +118,11 @@ func (c cInit) Index(ctx context.Context, in cInitInput) (out *cInitOutput, err
|
||||
}
|
||||
}
|
||||
|
||||
// Replace module name.
|
||||
if in.Module == "" {
|
||||
in.Module = gfile.Basename(gfile.RealPath(in.Name))
|
||||
}
|
||||
|
||||
// Replace template name to project name.
|
||||
err = gfile.ReplaceDirFunc(func(path, content string) string {
|
||||
for _, ignoreFile := range ignoreFiles {
|
||||
@ -125,7 +130,7 @@ func (c cInit) Index(ctx context.Context, in cInitInput) (out *cInitOutput, err
|
||||
return content
|
||||
}
|
||||
}
|
||||
return gstr.Replace(gfile.GetContents(path), cInitRepoPrefix+templateRepoName, gfile.Basename(gfile.RealPath(in.Name)))
|
||||
return gstr.Replace(gfile.GetContents(path), cInitRepoPrefix+templateRepoName, in.Module)
|
||||
}, in.Name, "*", true)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@ -99,6 +99,7 @@ func (c cRun) Index(ctx context.Context, in cRunInput) (out *cRunOutput, err err
|
||||
|
||||
if len(in.WatchPaths) == 1 {
|
||||
in.WatchPaths = strings.Split(in.WatchPaths[0], ",")
|
||||
mlog.Printf("watchPaths: %v", in.WatchPaths)
|
||||
}
|
||||
|
||||
app := &cRunApp{
|
||||
@ -109,8 +110,9 @@ func (c cRun) Index(ctx context.Context, in cRunInput) (out *cRunOutput, err err
|
||||
WatchPaths: in.WatchPaths,
|
||||
}
|
||||
dirty := gtype.NewBool()
|
||||
_, err = gfsnotify.Add(gfile.RealPath("."), func(event *gfsnotify.Event) {
|
||||
if gfile.ExtName(event.Path) != "go" && !matchWatchPaths(app.WatchPaths, event.Path) {
|
||||
|
||||
callbackFunc := func(event *gfsnotify.Event) {
|
||||
if gfile.ExtName(event.Path) != "go" {
|
||||
return
|
||||
}
|
||||
|
||||
@ -125,10 +127,22 @@ func (c cRun) Index(ctx context.Context, in cRunInput) (out *cRunOutput, err err
|
||||
mlog.Printf(`watched file changes: %s`, event.String())
|
||||
app.Run(ctx)
|
||||
})
|
||||
})
|
||||
if err != nil {
|
||||
mlog.Fatal(err)
|
||||
}
|
||||
|
||||
if len(app.WatchPaths) > 0 {
|
||||
for _, path := range app.WatchPaths {
|
||||
_, err = gfsnotify.Add(gfile.RealPath(path), callbackFunc)
|
||||
if err != nil {
|
||||
mlog.Fatal(err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_, err = gfsnotify.Add(gfile.RealPath("."), callbackFunc)
|
||||
if err != nil {
|
||||
mlog.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
go app.Run(ctx)
|
||||
select {}
|
||||
}
|
||||
|
||||
@ -393,3 +393,78 @@ func Test_Gen_Dao_Issue2616(t *testing.T) {
|
||||
t.Assert(gstr.Contains(daoUser2Content, keyStr), false)
|
||||
})
|
||||
}
|
||||
|
||||
// https://github.com/gogf/gf/issues/2746
|
||||
func Test_Gen_Dao_Issue2746(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
err error
|
||||
mdb gdb.DB
|
||||
link2746 = "mariadb:root:12345678@tcp(127.0.0.1:3307)/test?loc=Local&parseTime=true"
|
||||
table = "issue2746"
|
||||
sqlContent = fmt.Sprintf(
|
||||
gtest.DataContent(`issue`, `2746`, `sql.sql`),
|
||||
table,
|
||||
)
|
||||
)
|
||||
mdb, err = gdb.New(gdb.ConfigNode{
|
||||
Link: link2746,
|
||||
})
|
||||
t.AssertNil(err)
|
||||
|
||||
array := gstr.SplitAndTrim(sqlContent, ";")
|
||||
for _, v := range array {
|
||||
if _, err = mdb.Exec(ctx, v); err != nil {
|
||||
t.AssertNil(err)
|
||||
}
|
||||
}
|
||||
defer dropTableWithDb(mdb, table)
|
||||
|
||||
var (
|
||||
path = gfile.Temp(guid.S())
|
||||
group = "test"
|
||||
in = gendao.CGenDaoInput{
|
||||
Path: path,
|
||||
Link: link2746,
|
||||
Tables: "",
|
||||
TablesEx: "",
|
||||
Group: group,
|
||||
Prefix: "",
|
||||
RemovePrefix: "",
|
||||
JsonCase: "SnakeScreaming",
|
||||
ImportPrefix: "",
|
||||
DaoPath: "",
|
||||
DoPath: "",
|
||||
EntityPath: "",
|
||||
TplDaoIndexPath: "",
|
||||
TplDaoInternalPath: "",
|
||||
TplDaoDoPath: "",
|
||||
TplDaoEntityPath: "",
|
||||
StdTime: false,
|
||||
WithTime: false,
|
||||
GJsonSupport: true,
|
||||
OverwriteDao: false,
|
||||
DescriptionTag: false,
|
||||
NoJsonTag: false,
|
||||
NoModelComment: false,
|
||||
Clear: false,
|
||||
TypeMapping: nil,
|
||||
}
|
||||
)
|
||||
err = gutil.FillStructWithDefault(&in)
|
||||
t.AssertNil(err)
|
||||
|
||||
err = gfile.Mkdir(path)
|
||||
t.AssertNil(err)
|
||||
|
||||
_, err = gendao.CGenDao{}.Dao(ctx, in)
|
||||
t.AssertNil(err)
|
||||
defer gfile.Remove(path)
|
||||
|
||||
var (
|
||||
file = filepath.FromSlash(path + "/model/entity/issue_2746.go")
|
||||
expectContent = gtest.DataContent(`issue`, `2746`, `issue_2746.go`)
|
||||
)
|
||||
t.Assert(expectContent, gfile.GetContents(file))
|
||||
})
|
||||
}
|
||||
|
||||
@ -201,8 +201,8 @@ type (
|
||||
NoModelComment bool `name:"noModelComment" short:"m" brief:"{CGenDaoBriefNoModelComment}" orphan:"true"`
|
||||
Clear bool `name:"clear" short:"a" brief:"{CGenDaoBriefClear}" orphan:"true"`
|
||||
|
||||
TypeMapping map[DBFieldTypeName]CustomAttributeType `name:"typeMapping" short:"y" brief:"{CGenDaoBriefTypeMapping}" orphan:"true"`
|
||||
generatedFilePaths *CGenDaoInternalGeneratedFilePaths
|
||||
TypeMapping map[DBFieldTypeName]CustomAttributeType `name:"typeMapping" short:"y" brief:"{CGenDaoBriefTypeMapping}" orphan:"true"`
|
||||
genItems *CGenDaoInternalGenItems
|
||||
}
|
||||
CGenDaoOutput struct{}
|
||||
|
||||
@ -213,13 +213,6 @@ type (
|
||||
NewTableNames []string
|
||||
}
|
||||
|
||||
CGenDaoInternalGeneratedFilePaths struct {
|
||||
DaoFilePaths []string
|
||||
DaoInternalFilePaths []string
|
||||
DoFilePaths []string
|
||||
EntityFilePaths []string
|
||||
}
|
||||
|
||||
DBFieldTypeName = string
|
||||
CustomAttributeType struct {
|
||||
Type string `brief:"custom attribute type name"`
|
||||
@ -228,12 +221,7 @@ type (
|
||||
)
|
||||
|
||||
func (c CGenDao) Dao(ctx context.Context, in CGenDaoInput) (out *CGenDaoOutput, err error) {
|
||||
in.generatedFilePaths = &CGenDaoInternalGeneratedFilePaths{
|
||||
DaoFilePaths: make([]string, 0),
|
||||
DaoInternalFilePaths: make([]string, 0),
|
||||
DoFilePaths: make([]string, 0),
|
||||
EntityFilePaths: make([]string, 0),
|
||||
}
|
||||
in.genItems = newCGenDaoInternalGenItems()
|
||||
if g.Cfg().Available(ctx) {
|
||||
v := g.Cfg().MustGet(ctx, CGenDaoConfig)
|
||||
if v.IsSlice() {
|
||||
@ -246,6 +234,7 @@ func (c CGenDao) Dao(ctx context.Context, in CGenDaoInput) (out *CGenDaoOutput,
|
||||
} else {
|
||||
doGenDaoForArray(ctx, -1, in)
|
||||
}
|
||||
doClear(in.genItems)
|
||||
mlog.Print("done!")
|
||||
return
|
||||
}
|
||||
@ -326,6 +315,8 @@ func doGenDaoForArray(ctx context.Context, index int, in CGenDaoInput) {
|
||||
newTableNames[i] = newTableName
|
||||
}
|
||||
|
||||
in.genItems.Scale()
|
||||
|
||||
// Dao: index and internal.
|
||||
generateDao(ctx, CGenDaoInternalInput{
|
||||
CGenDaoInput: in,
|
||||
@ -348,9 +339,7 @@ func doGenDaoForArray(ctx context.Context, index int, in CGenDaoInput) {
|
||||
NewTableNames: newTableNames,
|
||||
})
|
||||
|
||||
if in.Clear {
|
||||
doClear(ctx, in)
|
||||
}
|
||||
in.genItems.SetClear(in.Clear)
|
||||
}
|
||||
|
||||
func getImportPartContent(ctx context.Context, source string, isDo bool, appendImports []string) string {
|
||||
|
||||
@ -7,27 +7,40 @@
|
||||
package gendao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gfile"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
|
||||
"github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
|
||||
)
|
||||
|
||||
func doClear(ctx context.Context, in CGenDaoInput) {
|
||||
filePaths, err := gfile.ScanDirFile(in.Path, "*.go", true)
|
||||
if err != nil {
|
||||
mlog.Fatal(err)
|
||||
}
|
||||
func doClear(items *CGenDaoInternalGenItems) {
|
||||
var allGeneratedFilePaths = make([]string, 0)
|
||||
allGeneratedFilePaths = append(allGeneratedFilePaths, in.generatedFilePaths.DaoFilePaths...)
|
||||
allGeneratedFilePaths = append(allGeneratedFilePaths, in.generatedFilePaths.DaoInternalFilePaths...)
|
||||
allGeneratedFilePaths = append(allGeneratedFilePaths, in.generatedFilePaths.EntityFilePaths...)
|
||||
allGeneratedFilePaths = append(allGeneratedFilePaths, in.generatedFilePaths.DoFilePaths...)
|
||||
for _, filePath := range filePaths {
|
||||
for _, item := range items.Items {
|
||||
allGeneratedFilePaths = append(allGeneratedFilePaths, item.GeneratedFilePaths...)
|
||||
}
|
||||
for i, v := range allGeneratedFilePaths {
|
||||
allGeneratedFilePaths[i] = gfile.RealPath(v)
|
||||
}
|
||||
for _, item := range items.Items {
|
||||
if !item.Clear {
|
||||
continue
|
||||
}
|
||||
doClearItem(item, allGeneratedFilePaths)
|
||||
}
|
||||
}
|
||||
|
||||
func doClearItem(item CGenDaoInternalGenItem, allGeneratedFilePaths []string) {
|
||||
var generatedFilePaths = make([]string, 0)
|
||||
for _, dirPath := range item.StorageDirPaths {
|
||||
filePaths, err := gfile.ScanDirFile(dirPath, "*.go", true)
|
||||
if err != nil {
|
||||
mlog.Fatal(err)
|
||||
}
|
||||
generatedFilePaths = append(generatedFilePaths, filePaths...)
|
||||
}
|
||||
for _, filePath := range generatedFilePaths {
|
||||
if !gstr.InArray(allGeneratedFilePaths, filePath) {
|
||||
if err = gfile.Remove(filePath); err != nil {
|
||||
if err := gfile.Remove(filePath); err != nil {
|
||||
mlog.Print(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ func generateDao(ctx context.Context, in CGenDaoInternalInput) {
|
||||
dirPathDao = gfile.Join(in.Path, in.DaoPath)
|
||||
dirPathDaoInternal = gfile.Join(dirPathDao, "internal")
|
||||
)
|
||||
in.genItems.AppendDirPath(dirPathDao)
|
||||
for i := 0; i < len(in.TableNames); i++ {
|
||||
generateDaoSingle(ctx, generateDaoSingleInput{
|
||||
CGenDaoInternalInput: in,
|
||||
@ -106,10 +107,7 @@ type generateDaoIndexInput struct {
|
||||
func generateDaoIndex(in generateDaoIndexInput) {
|
||||
path := filepath.FromSlash(gfile.Join(in.DirPathDao, in.FileName+".go"))
|
||||
// It should add path to result slice whenever it would generate the path file or not.
|
||||
in.generatedFilePaths.DaoFilePaths = append(
|
||||
in.generatedFilePaths.DaoFilePaths,
|
||||
path,
|
||||
)
|
||||
in.genItems.AppendGeneratedFilePath(path)
|
||||
if in.OverwriteDao || !gfile.Exists(path) {
|
||||
indexContent := gstr.ReplaceByMap(
|
||||
getTemplateFromPathOrDefault(in.TplDaoIndexPath, consts.TemplateGenDaoIndexContent),
|
||||
@ -153,10 +151,7 @@ func generateDaoInternal(in generateDaoInternalInput) {
|
||||
tplVarColumnNames: gstr.Trim(generateColumnNamesForDao(in.FieldMap, removeFieldPrefixArray)),
|
||||
})
|
||||
modelContent = replaceDefaultVar(in.CGenDaoInternalInput, modelContent)
|
||||
in.generatedFilePaths.DaoInternalFilePaths = append(
|
||||
in.generatedFilePaths.DaoInternalFilePaths,
|
||||
path,
|
||||
)
|
||||
in.genItems.AppendGeneratedFilePath(path)
|
||||
if err := gfile.PutContents(path, strings.TrimSpace(modelContent)); err != nil {
|
||||
mlog.Fatalf("writing content to '%s' failed: %v", path, err)
|
||||
} else {
|
||||
|
||||
@ -24,6 +24,7 @@ import (
|
||||
|
||||
func generateDo(ctx context.Context, in CGenDaoInternalInput) {
|
||||
var dirPathDo = filepath.FromSlash(gfile.Join(in.Path, in.DoPath))
|
||||
in.genItems.AppendDirPath(dirPathDo)
|
||||
in.NoJsonTag = true
|
||||
in.DescriptionTag = false
|
||||
in.NoModelComment = false
|
||||
@ -63,10 +64,7 @@ func generateDo(ctx context.Context, in CGenDaoInternalInput) {
|
||||
gstr.CaseCamel(newTableName),
|
||||
structDefinition,
|
||||
)
|
||||
in.generatedFilePaths.DoFilePaths = append(
|
||||
in.generatedFilePaths.DoFilePaths,
|
||||
doFilePath,
|
||||
)
|
||||
in.genItems.AppendGeneratedFilePath(doFilePath)
|
||||
err = gfile.PutContents(doFilePath, strings.TrimSpace(modelContent))
|
||||
if err != nil {
|
||||
mlog.Fatalf(`writing content to "%s" failed: %v`, doFilePath, err)
|
||||
|
||||
@ -22,6 +22,7 @@ import (
|
||||
|
||||
func generateEntity(ctx context.Context, in CGenDaoInternalInput) {
|
||||
var dirPathEntity = gfile.Join(in.Path, in.EntityPath)
|
||||
in.genItems.AppendDirPath(dirPathEntity)
|
||||
// Model content.
|
||||
for i, tableName := range in.TableNames {
|
||||
fieldMap, err := in.DB.TableFields(ctx, tableName)
|
||||
@ -48,10 +49,7 @@ func generateEntity(ctx context.Context, in CGenDaoInternalInput) {
|
||||
appendImports,
|
||||
)
|
||||
)
|
||||
in.generatedFilePaths.EntityFilePaths = append(
|
||||
in.generatedFilePaths.EntityFilePaths,
|
||||
entityFilePath,
|
||||
)
|
||||
in.genItems.AppendGeneratedFilePath(entityFilePath)
|
||||
err = gfile.PutContents(entityFilePath, strings.TrimSpace(entityContent))
|
||||
if err != nil {
|
||||
mlog.Fatalf("writing content to '%s' failed: %v", entityFilePath, err)
|
||||
|
||||
53
cmd/gf/internal/cmd/gendao/gendao_gen_item.go
Normal file
53
cmd/gf/internal/cmd/gendao/gendao_gen_item.go
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package gendao
|
||||
|
||||
type (
|
||||
CGenDaoInternalGenItems struct {
|
||||
index int
|
||||
Items []CGenDaoInternalGenItem
|
||||
}
|
||||
CGenDaoInternalGenItem struct {
|
||||
Clear bool
|
||||
StorageDirPaths []string
|
||||
GeneratedFilePaths []string
|
||||
}
|
||||
)
|
||||
|
||||
func newCGenDaoInternalGenItems() *CGenDaoInternalGenItems {
|
||||
return &CGenDaoInternalGenItems{
|
||||
index: -1,
|
||||
Items: make([]CGenDaoInternalGenItem, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (i *CGenDaoInternalGenItems) Scale() {
|
||||
i.Items = append(i.Items, CGenDaoInternalGenItem{
|
||||
StorageDirPaths: make([]string, 0),
|
||||
GeneratedFilePaths: make([]string, 0),
|
||||
Clear: false,
|
||||
})
|
||||
i.index++
|
||||
}
|
||||
|
||||
func (i *CGenDaoInternalGenItems) SetClear(clear bool) {
|
||||
i.Items[i.index].Clear = clear
|
||||
}
|
||||
|
||||
func (i CGenDaoInternalGenItems) AppendDirPath(storageDirPath string) {
|
||||
i.Items[i.index].StorageDirPaths = append(
|
||||
i.Items[i.index].StorageDirPaths,
|
||||
storageDirPath,
|
||||
)
|
||||
}
|
||||
|
||||
func (i CGenDaoInternalGenItems) AppendGeneratedFilePath(generatedFilePath string) {
|
||||
i.Items[i.index].GeneratedFilePaths = append(
|
||||
i.Items[i.index].GeneratedFilePaths,
|
||||
generatedFilePath,
|
||||
)
|
||||
}
|
||||
@ -135,9 +135,14 @@ func generateStructFieldDefinition(
|
||||
" #" + gstr.CaseCamel(newFiledName),
|
||||
" #" + localTypeNameStr,
|
||||
}
|
||||
attrLines = append(attrLines, " #"+fmt.Sprintf(tagKey+`json:"%s"`, jsonTag))
|
||||
attrLines = append(attrLines, " #"+fmt.Sprintf(`description:"%s"`+tagKey, descriptionTag))
|
||||
attrLines = append(attrLines, " #"+fmt.Sprintf(`// %s`, formatComment(field.Comment)))
|
||||
attrLines = append(attrLines, fmt.Sprintf(` #%sjson:"%s"`, tagKey, jsonTag))
|
||||
// orm tag
|
||||
if !in.IsDo {
|
||||
// entity
|
||||
attrLines = append(attrLines, fmt.Sprintf(` #orm:"%s"`, field.Name))
|
||||
}
|
||||
attrLines = append(attrLines, fmt.Sprintf(` #description:"%s"%s`, descriptionTag, tagKey))
|
||||
attrLines = append(attrLines, fmt.Sprintf(` #// %s`, formatComment(field.Comment)))
|
||||
|
||||
for k, v := range attrLines {
|
||||
if in.NoJsonTag {
|
||||
|
||||
@ -3,18 +3,17 @@ github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyM
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=
|
||||
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
|
||||
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
|
||||
|
||||
@ -10,11 +10,11 @@ import (
|
||||
|
||||
// TableUser is the golang structure for table table_user.
|
||||
type TableUser struct {
|
||||
Id uint `json:"ID" ` // User ID
|
||||
Passport string `json:"PASSPORT" ` // User Passport
|
||||
Password string `json:"PASSWORD" ` // User Password
|
||||
Nickname string `json:"NICKNAME" ` // User Nickname
|
||||
Score float64 `json:"SCORE" ` // Total score amount.
|
||||
CreateAt *gtime.Time `json:"CREATE_AT" ` // Created Time
|
||||
UpdateAt *gtime.Time `json:"UPDATE_AT" ` // Updated Time
|
||||
Id uint `json:"ID" orm:"id" ` // User ID
|
||||
Passport string `json:"PASSPORT" orm:"passport" ` // User Passport
|
||||
Password string `json:"PASSWORD" orm:"password" ` // User Password
|
||||
Nickname string `json:"NICKNAME" orm:"nickname" ` // User Nickname
|
||||
Score float64 `json:"SCORE" orm:"score" ` // Total score amount.
|
||||
CreateAt *gtime.Time `json:"CREATE_AT" orm:"create_at" ` // Created Time
|
||||
UpdateAt *gtime.Time `json:"UPDATE_AT" orm:"update_at" ` // Updated Time
|
||||
}
|
||||
|
||||
@ -11,11 +11,11 @@ import (
|
||||
|
||||
// TableUser is the golang structure for table table_user.
|
||||
type TableUser struct {
|
||||
Id int64 `json:"id" ` // User ID
|
||||
Passport string `json:"passport" ` // User Passport
|
||||
Password string `json:"password" ` // User Password
|
||||
Nickname string `json:"nickname" ` // User Nickname
|
||||
Score decimal.Decimal `json:"score" ` // Total score amount.
|
||||
CreateAt *gtime.Time `json:"createAt" ` // Created Time
|
||||
UpdateAt *gtime.Time `json:"updateAt" ` // Updated Time
|
||||
Id int64 `json:"id" orm:"id" ` // User ID
|
||||
Passport string `json:"passport" orm:"passport" ` // User Passport
|
||||
Password string `json:"password" orm:"password" ` // User Password
|
||||
Nickname string `json:"nickname" orm:"nickname" ` // User Nickname
|
||||
Score decimal.Decimal `json:"score" orm:"score" ` // Total score amount.
|
||||
CreateAt *gtime.Time `json:"createAt" orm:"create_at" ` // Created Time
|
||||
UpdateAt *gtime.Time `json:"updateAt" orm:"update_at" ` // Updated Time
|
||||
}
|
||||
|
||||
18
cmd/gf/internal/cmd/testdata/issue/2746/issue_2746.go
vendored
Normal file
18
cmd/gf/internal/cmd/testdata/issue/2746/issue_2746.go
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
)
|
||||
|
||||
// Issue2746 is the golang structure for table issue2746.
|
||||
type Issue2746 struct {
|
||||
Id uint `json:"ID" orm:"id" ` // User ID
|
||||
Nickname string `json:"NICKNAME" orm:"nickname" ` // User Nickname
|
||||
Tag *gjson.Json `json:"TAG" orm:"tag" ` //
|
||||
Info string `json:"INFO" orm:"info" ` //
|
||||
Tag2 *gjson.Json `json:"TAG_2" orm:"tag2" ` // Tag2
|
||||
}
|
||||
9
cmd/gf/internal/cmd/testdata/issue/2746/sql.sql
vendored
Normal file
9
cmd/gf/internal/cmd/testdata/issue/2746/sql.sql
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
CREATE TABLE %s (
|
||||
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID',
|
||||
`nickname` varchar(45) NOT NULL COMMENT 'User Nickname',
|
||||
`tag` json NOT NULL,
|
||||
`info` longtext DEFAULT NULL,
|
||||
`tag2` json COMMENT 'Tag2',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
@ -25,7 +25,7 @@ type Pool struct {
|
||||
closed *gtype.Bool // Whether the pool is closed.
|
||||
TTL time.Duration // Time To Live for pool items.
|
||||
NewFunc func() (interface{}, error) // Callback function to create pool item.
|
||||
// ExpireFunc is the for expired items destruction.
|
||||
// ExpireFunc is the function for expired items destruction.
|
||||
// This function needs to be defined when the pool items
|
||||
// need to perform additional destruction operations.
|
||||
// Eg: net.Conn, os.File, etc.
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
// Package gtype provides high performance and concurrent-safe basic variable types.
|
||||
package gtype
|
||||
|
||||
// New is alias of NewInterface.
|
||||
// See NewInterface.
|
||||
func New(value ...interface{}) *Interface {
|
||||
return NewInterface(value...)
|
||||
// New is alias of NewAny.
|
||||
// See NewAny, NewInterface.
|
||||
func New(value ...interface{}) *Any {
|
||||
return NewAny(value...)
|
||||
}
|
||||
|
||||
20
container/gtype/gtype_any.go
Normal file
20
container/gtype/gtype_any.go
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package gtype
|
||||
|
||||
// Any is a struct for concurrent-safe operation for type any.
|
||||
type Any = Interface
|
||||
|
||||
// NewAny creates and returns a concurrent-safe object for any type,
|
||||
// with given initial value `value`.
|
||||
func NewAny(value ...any) *Any {
|
||||
t := &Any{}
|
||||
if len(value) > 0 && value[0] != nil {
|
||||
t.value.Store(value[0])
|
||||
}
|
||||
return t
|
||||
}
|
||||
74
container/gtype/gtype_z_unit_any_test.go
Normal file
74
container/gtype/gtype_z_unit_any_test.go
Normal file
@ -0,0 +1,74 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package gtype_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gogf/gf/v2/container/gtype"
|
||||
"github.com/gogf/gf/v2/internal/json"
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
func Test_Any(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t1 := Temp{Name: "gf", Age: 18}
|
||||
t2 := Temp{Name: "gf", Age: 19}
|
||||
i := gtype.New(t1)
|
||||
iClone := i.Clone()
|
||||
t.AssertEQ(iClone.Set(t2), t1)
|
||||
t.AssertEQ(iClone.Val().(Temp), t2)
|
||||
|
||||
// empty param test
|
||||
i1 := gtype.New()
|
||||
t.AssertEQ(i1.Val(), nil)
|
||||
|
||||
i2 := gtype.New("gf")
|
||||
t.AssertEQ(i2.String(), "gf")
|
||||
copyVal := i2.DeepCopy()
|
||||
i2.Set("goframe")
|
||||
t.AssertNE(copyVal, iClone.Val())
|
||||
i2 = nil
|
||||
copyVal = i2.DeepCopy()
|
||||
t.AssertNil(copyVal)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Any_JSON(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
s := "i love gf"
|
||||
i := gtype.New(s)
|
||||
b1, err1 := json.Marshal(i)
|
||||
b2, err2 := json.Marshal(i.Val())
|
||||
t.Assert(err1, nil)
|
||||
t.Assert(err2, nil)
|
||||
t.Assert(b1, b2)
|
||||
|
||||
i2 := gtype.New()
|
||||
err := json.UnmarshalUseNumber(b2, &i2)
|
||||
t.AssertNil(err)
|
||||
t.Assert(i2.Val(), s)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Any_UnmarshalValue(t *testing.T) {
|
||||
type V struct {
|
||||
Name string
|
||||
Var *gtype.Any
|
||||
}
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var v *V
|
||||
err := gconv.Struct(map[string]any{
|
||||
"name": "john",
|
||||
"var": "123",
|
||||
}, &v)
|
||||
t.AssertNil(err)
|
||||
t.Assert(v.Name, "john")
|
||||
t.Assert(v.Var.Val(), "123")
|
||||
})
|
||||
}
|
||||
@ -4,7 +4,7 @@ go 1.18
|
||||
|
||||
require (
|
||||
github.com/apolloconfig/agollo/v4 v4.3.1
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
module github.com/gogf/gf/contrib/config/consul/v2
|
||||
|
||||
go 1.19
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
github.com/hashicorp/consul/api v1.24.0
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2
|
||||
)
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
module github.com/gogf/gf/contrib/config/kubecm/v2
|
||||
|
||||
go 1.19
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
k8s.io/api v0.27.4
|
||||
k8s.io/apimachinery v0.27.4
|
||||
k8s.io/client-go v0.27.4
|
||||
|
||||
@ -23,8 +23,8 @@ import (
|
||||
"github.com/gogf/gf/contrib/config/nacos/v2"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/nacos-group/nacos-sdk-go/common/constant"
|
||||
"github.com/nacos-group/nacos-sdk-go/vo"
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/vo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@ -3,20 +3,28 @@ module github.com/gogf/gf/contrib/config/nacos/v2
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/nacos-group/nacos-sdk-go v1.1.4
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.5
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.0 // indirect
|
||||
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
|
||||
github.com/alibabacloud-go/tea v1.1.17 // indirect
|
||||
github.com/alibabacloud-go/tea-utils v1.4.4 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.62.589 // indirect
|
||||
github.com/aliyun/alibabacloud-dkms-gcs-go-sdk v0.2.2 // indirect
|
||||
github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.7 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/go-errors/errors v1.5.1 // indirect
|
||||
github.com/go-logr/logr v1.2.4 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/grokify/html-strip-tags-go v0.0.1 // indirect
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
|
||||
@ -25,11 +33,16 @@ require (
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/prometheus/client_golang v1.12.2 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.32.1 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
go.opentelemetry.io/otel v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
|
||||
@ -37,10 +50,15 @@ require (
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.21.0 // indirect
|
||||
golang.org/x/crypto v0.17.0 // indirect
|
||||
golang.org/x/net v0.17.0 // indirect
|
||||
golang.org/x/sync v0.4.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
golang.org/x/sys v0.15.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.1.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
|
||||
google.golang.org/grpc v1.56.3 // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
@ -1,3 +1,35 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
|
||||
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
|
||||
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
|
||||
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
|
||||
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
|
||||
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
|
||||
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
|
||||
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
||||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
||||
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
|
||||
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
|
||||
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
||||
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
|
||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
|
||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||
@ -5,55 +37,157 @@ github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
|
||||
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 h1:NqugFkGxx1TXSh/pBcU00Y6bljgDPaFdh5MUSeJ7e50=
|
||||
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY=
|
||||
github.com/alibabacloud-go/tea v1.1.0/go.mod h1:IkGyUSX4Ba1V+k4pCtJUc6jDpZLFph9QMy2VUPTwukg=
|
||||
github.com/alibabacloud-go/tea v1.1.17 h1:05R5DnaJXe9sCNIe8KUgWHC/z6w/VZIwczgUwzRnul8=
|
||||
github.com/alibabacloud-go/tea v1.1.17/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A=
|
||||
github.com/alibabacloud-go/tea-utils v1.4.4 h1:lxCDvNCdTo9FaXKKq45+4vGETQUKNOW/qKTcX9Sk53o=
|
||||
github.com/alibabacloud-go/tea-utils v1.4.4/go.mod h1:KNcT0oXlZZxOXINnZBs6YvgOd5aYp9U67G+E3R8fcQw=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1800/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.62.589 h1:G0ct80P/GKraO8BIZnkuzzNho/3x2QoWnXWdEmW+1Ok=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.62.589/go.mod h1:CJJYa1ZMxjlN/NbXEwmejEnBkhi0DV+Yb3B2lxf+74o=
|
||||
github.com/aliyun/alibabacloud-dkms-gcs-go-sdk v0.2.2 h1:rWkH6D2XlXb/Y+tNAQROxBzp3a0p92ni+pXcaHBe/WI=
|
||||
github.com/aliyun/alibabacloud-dkms-gcs-go-sdk v0.2.2/go.mod h1:GDtq+Kw+v0fO+j5BrrWiUHbBq7L+hfpzpPfXKOZMFE0=
|
||||
github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.7 h1:olLiPI2iM8Hqq6vKnSxpM3awCrm9/BeOgHpzQkOYnI4=
|
||||
github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.7/go.mod h1:oDg1j4kFxnhgftaiLJABkGeSvuEvSF5Lo6UmRAMruX4=
|
||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
|
||||
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8bk=
|
||||
github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
||||
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=
|
||||
github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
@ -69,6 +203,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
@ -76,108 +212,281 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/nacos-group/nacos-sdk-go v1.1.4 h1:qyrZ7HTWM4aeymFfqnbgNRERh7TWuER10pCB7ddRcTY=
|
||||
github.com/nacos-group/nacos-sdk-go v1.1.4/go.mod h1:cBv9wy5iObs7khOqov1ERFQrCuTR4ILpgaiaVMxEmGI=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 h1:r0wwT7PayEjvEHzWXwr1ROi/JSqzujM4w+1L5ikThzQ=
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.5/go.mod h1:OObBon0prVJVPoIbSZxpEkFiBfL0d1LcBtuAMiNn+8c=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b h1:FfH+VrHHk6Lxt9HdVS0PXzSXFyS2NbZKXv33FYPol0A=
|
||||
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b/go.mod h1:AC62GU6hc0BrNm+9RK9VSiwa/EUe1bkIeFORAMcHvJU=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||
github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34=
|
||||
github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
||||
github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
|
||||
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
|
||||
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
|
||||
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o=
|
||||
github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
|
||||
github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg=
|
||||
github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
|
||||
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
|
||||
go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY=
|
||||
go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM=
|
||||
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
|
||||
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
|
||||
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
|
||||
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
|
||||
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA=
|
||||
golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -187,25 +496,120 @@ gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJ
|
||||
gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0=
|
||||
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
|
||||
gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
|
||||
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
|
||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
|
||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc=
|
||||
google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
|
||||
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
|
||||
@ -10,14 +10,15 @@ package nacos
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/clients"
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/clients/config_client"
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/vo"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gcfg"
|
||||
"github.com/nacos-group/nacos-sdk-go/clients"
|
||||
"github.com/nacos-group/nacos-sdk-go/clients/config_client"
|
||||
"github.com/nacos-group/nacos-sdk-go/common/constant"
|
||||
"github.com/nacos-group/nacos-sdk-go/vo"
|
||||
)
|
||||
|
||||
// Config is the configuration object for nacos client.
|
||||
|
||||
@ -9,14 +9,14 @@ package nacos_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
|
||||
"github.com/nacos-group/nacos-sdk-go/v2/vo"
|
||||
|
||||
"github.com/gogf/gf/contrib/config/nacos/v2"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
"github.com/gogf/gf/v2/util/guid"
|
||||
"github.com/nacos-group/nacos-sdk-go/common/constant"
|
||||
"github.com/nacos-group/nacos-sdk-go/vo"
|
||||
|
||||
"github.com/gogf/gf/contrib/config/nacos/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/polaris/v2
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
github.com/polarismesh/polaris-go v1.5.5
|
||||
)
|
||||
|
||||
|
||||
@ -39,23 +39,20 @@ import _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
||||
```
|
||||
import _ "github.com/gogf/gf/contrib/drivers/sqlite/v2"
|
||||
```
|
||||
Note:
|
||||
- It does not support `Save` features.
|
||||
|
||||
## PostgreSQL
|
||||
```
|
||||
import _ "github.com/gogf/gf/contrib/drivers/pgsql/v2"
|
||||
```
|
||||
Note:
|
||||
- It does not support `Save/Replace` features.
|
||||
- It does not support `LastInsertId`.
|
||||
- It does not support `Replace` features.
|
||||
|
||||
## SQL Server
|
||||
```
|
||||
import _ "github.com/gogf/gf/contrib/drivers/mssql/v2"
|
||||
```
|
||||
Note:
|
||||
- It does not support `Save/Replace` features.
|
||||
- It does not support `Replace` features.
|
||||
- It does not support `LastInsertId`.
|
||||
- It supports server version >= `SQL Server2005`
|
||||
- It ONLY supports datetime2 and datetimeoffset types for auto handling created_at/updated_at/deleted_at columns, because datetime type does not support microseconds precision when column value is passed as string.
|
||||
@ -65,7 +62,7 @@ Note:
|
||||
import _ "github.com/gogf/gf/contrib/drivers/oracle/v2"
|
||||
```
|
||||
Note:
|
||||
- It does not support `Save/Replace` features.
|
||||
- It does not support `Replace` features.
|
||||
- It does not support `LastInsertId`.
|
||||
|
||||
## ClickHouse
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
)
|
||||
|
||||
// DoInsert inserts or updates data forF given table.
|
||||
// DoInsert inserts or updates data for given table.
|
||||
func (d *Driver) DoInsert(
|
||||
ctx context.Context, link gdb.Link, table string, list gdb.List, option gdb.DoInsertOption,
|
||||
) (result sql.Result, err error) {
|
||||
|
||||
@ -4,7 +4,7 @@ go 1.18
|
||||
|
||||
require (
|
||||
github.com/ClickHouse/clickhouse-go/v2 v2.0.15
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/shopspring/decimal v1.3.1
|
||||
)
|
||||
|
||||
@ -10,198 +10,142 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/container/gset"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
// DoInsert inserts or updates data forF given table.
|
||||
// DoInsert inserts or updates data for given table.
|
||||
func (d *Driver) DoInsert(
|
||||
ctx context.Context, link gdb.Link, table string, list gdb.List, option gdb.DoInsertOption,
|
||||
) (result sql.Result, err error) {
|
||||
switch option.InsertOption {
|
||||
case gdb.InsertOptionSave:
|
||||
return d.doSave(ctx, link, table, list, option)
|
||||
|
||||
case gdb.InsertOptionReplace:
|
||||
// TODO:: Should be Supported
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeNotSupported, `Replace operation is not supported by dm driver`,
|
||||
)
|
||||
|
||||
case gdb.InsertOptionSave:
|
||||
// This syntax currently only supports design tables whose primary key is ID.
|
||||
listLength := len(list)
|
||||
if listLength == 0 {
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeInvalidRequest, `Save operation list is empty by dm driver`,
|
||||
)
|
||||
}
|
||||
var (
|
||||
keysSort []string
|
||||
charL, charR = d.GetChars()
|
||||
)
|
||||
// Column names need to be aligned in the syntax
|
||||
for k := range list[0] {
|
||||
keysSort = append(keysSort, k)
|
||||
}
|
||||
var char = struct {
|
||||
charL string
|
||||
charR string
|
||||
valueCharL string
|
||||
valueCharR string
|
||||
duplicateKey string
|
||||
keys []string
|
||||
}{
|
||||
charL: charL,
|
||||
charR: charR,
|
||||
valueCharL: "'",
|
||||
valueCharR: "'",
|
||||
// TODO:: Need to dynamically set the primary key of the table
|
||||
duplicateKey: "ID",
|
||||
keys: keysSort,
|
||||
}
|
||||
|
||||
// insertKeys: Handle valid keys that need to be inserted and updated
|
||||
// insertValues: Handle values that need to be inserted
|
||||
// updateValues: Handle values that need to be updated
|
||||
// queryValues: Handle only one insert with column name
|
||||
insertKeys, insertValues, updateValues, queryValues := parseValue(list[0], char)
|
||||
// unionValues: Handling values that need to be inserted and updated
|
||||
unionValues := parseUnion(list[1:], char)
|
||||
|
||||
batchResult := new(gdb.SqlResult)
|
||||
// parseSql():
|
||||
// MERGE INTO {{table}} T1
|
||||
// USING ( SELECT {{queryValues}} FROM DUAL
|
||||
// {{unionValues}} ) T2
|
||||
// ON (T1.{{duplicateKey}} = T2.{{duplicateKey}})
|
||||
// WHEN NOT MATCHED THEN
|
||||
// INSERT {{insertKeys}} VALUES {{insertValues}}
|
||||
// WHEN MATCHED THEN
|
||||
// UPDATE SET {{updateValues}}
|
||||
sqlStr := parseSql(
|
||||
insertKeys, insertValues, updateValues, queryValues, unionValues, table, char.duplicateKey,
|
||||
)
|
||||
r, err := d.DoExec(ctx, link, sqlStr)
|
||||
if err != nil {
|
||||
return r, err
|
||||
}
|
||||
if n, err := r.RowsAffected(); err != nil {
|
||||
return r, err
|
||||
} else {
|
||||
batchResult.Result = r
|
||||
batchResult.Affected += n
|
||||
}
|
||||
return batchResult, nil
|
||||
}
|
||||
|
||||
return d.Core.DoInsert(ctx, link, table, list, option)
|
||||
}
|
||||
|
||||
func parseValue(listOne gdb.Map, char struct {
|
||||
charL string
|
||||
charR string
|
||||
valueCharL string
|
||||
valueCharR string
|
||||
duplicateKey string
|
||||
keys []string
|
||||
}) (insertKeys []string, insertValues []string, updateValues []string, queryValues []string) {
|
||||
for _, column := range char.keys {
|
||||
if listOne[column] == nil {
|
||||
// remove unassigned struct object
|
||||
continue
|
||||
}
|
||||
insertKeys = append(insertKeys, char.charL+column+char.charR)
|
||||
insertValues = append(insertValues, "T2."+char.charL+column+char.charR)
|
||||
if column != char.duplicateKey {
|
||||
// doSave support upsert for dm
|
||||
func (d *Driver) doSave(ctx context.Context,
|
||||
link gdb.Link, table string, list gdb.List, option gdb.DoInsertOption,
|
||||
) (result sql.Result, err error) {
|
||||
if len(option.OnConflict) == 0 {
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeMissingParameter, `Please specify conflict columns`,
|
||||
)
|
||||
}
|
||||
|
||||
if len(list) == 0 {
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeInvalidRequest, `Save operation list is empty by oracle driver`,
|
||||
)
|
||||
}
|
||||
|
||||
var (
|
||||
one = list[0]
|
||||
oneLen = len(one)
|
||||
charL, charR = d.GetChars()
|
||||
|
||||
conflictKeys = option.OnConflict
|
||||
conflictKeySet = gset.New(false)
|
||||
|
||||
// queryHolders: Handle data with Holder that need to be upsert
|
||||
// queryValues: Handle data that need to be upsert
|
||||
// insertKeys: Handle valid keys that need to be inserted
|
||||
// insertValues: Handle values that need to be inserted
|
||||
// updateValues: Handle values that need to be updated
|
||||
queryHolders = make([]string, oneLen)
|
||||
queryValues = make([]interface{}, oneLen)
|
||||
insertKeys = make([]string, oneLen)
|
||||
insertValues = make([]string, oneLen)
|
||||
updateValues []string
|
||||
)
|
||||
|
||||
// conflictKeys slice type conv to set type
|
||||
for _, conflictKey := range conflictKeys {
|
||||
conflictKeySet.Add(gstr.ToUpper(conflictKey))
|
||||
}
|
||||
|
||||
index := 0
|
||||
for key, value := range one {
|
||||
keyWithChar := charL + key + charR
|
||||
queryHolders[index] = fmt.Sprintf("? AS %s", keyWithChar)
|
||||
queryValues[index] = value
|
||||
insertKeys[index] = keyWithChar
|
||||
insertValues[index] = fmt.Sprintf("T2.%s", keyWithChar)
|
||||
|
||||
// filter conflict keys in updateValues.
|
||||
// And the key is not a soft created field.
|
||||
if !(conflictKeySet.Contains(key) || d.Core.IsSoftCreatedFieldName(key)) {
|
||||
updateValues = append(
|
||||
updateValues,
|
||||
fmt.Sprintf(`T1.%s = T2.%s`, char.charL+column+char.charR, char.charL+column+char.charR),
|
||||
fmt.Sprintf(`T1.%s = T2.%s`, keyWithChar, keyWithChar),
|
||||
)
|
||||
}
|
||||
|
||||
saveValue := gconv.String(listOne[column])
|
||||
queryValues = append(
|
||||
queryValues,
|
||||
fmt.Sprintf(
|
||||
char.valueCharL+"%s"+char.valueCharR+" AS "+char.charL+"%s"+char.charR,
|
||||
saveValue, column,
|
||||
),
|
||||
)
|
||||
index++
|
||||
}
|
||||
return
|
||||
|
||||
batchResult := new(gdb.SqlResult)
|
||||
sqlStr := parseSqlForUpsert(table, queryHolders, insertKeys, insertValues, updateValues, conflictKeys)
|
||||
r, err := d.DoExec(ctx, link, sqlStr, queryValues...)
|
||||
if err != nil {
|
||||
return r, err
|
||||
}
|
||||
if n, err := r.RowsAffected(); err != nil {
|
||||
return r, err
|
||||
} else {
|
||||
batchResult.Result = r
|
||||
batchResult.Affected += n
|
||||
}
|
||||
return batchResult, nil
|
||||
}
|
||||
|
||||
func parseUnion(list gdb.List, char struct {
|
||||
charL string
|
||||
charR string
|
||||
valueCharL string
|
||||
valueCharR string
|
||||
duplicateKey string
|
||||
keys []string
|
||||
}) (unionValues []string) {
|
||||
for _, mapper := range list {
|
||||
var saveValue []string
|
||||
for _, column := range char.keys {
|
||||
if mapper[column] == nil {
|
||||
continue
|
||||
}
|
||||
// va := reflect.ValueOf(mapper[column])
|
||||
// ty := reflect.TypeOf(mapper[column])
|
||||
// switch ty.Kind() {
|
||||
// case reflect.String:
|
||||
// saveValue = append(saveValue, char.valueCharL+va.String()+char.valueCharR)
|
||||
|
||||
// case reflect.Int:
|
||||
// saveValue = append(saveValue, strconv.FormatInt(va.Int(), 10))
|
||||
|
||||
// case reflect.Int64:
|
||||
// saveValue = append(saveValue, strconv.FormatInt(va.Int(), 10))
|
||||
|
||||
// default:
|
||||
// // The fish has no chance getting here.
|
||||
// // Nothing to do.
|
||||
// }
|
||||
saveValue = append(saveValue,
|
||||
fmt.Sprintf(
|
||||
char.valueCharL+"%s"+char.valueCharR,
|
||||
gconv.String(mapper[column]),
|
||||
))
|
||||
}
|
||||
unionValues = append(
|
||||
unionValues,
|
||||
fmt.Sprintf(`UNION ALL SELECT %s FROM DUAL`, strings.Join(saveValue, ",")),
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func parseSql(
|
||||
insertKeys, insertValues, updateValues, queryValues, unionValues []string, table, duplicateKey string,
|
||||
// parseSqlForUpsert
|
||||
// MERGE INTO {{table}} T1
|
||||
// USING ( SELECT {{queryHolders}} FROM DUAL T2
|
||||
// ON (T1.{{duplicateKey}} = T2.{{duplicateKey}} AND ...)
|
||||
// WHEN NOT MATCHED THEN
|
||||
// INSERT {{insertKeys}} VALUES {{insertValues}}
|
||||
// WHEN MATCHED THEN
|
||||
// UPDATE SET {{updateValues}}
|
||||
func parseSqlForUpsert(table string,
|
||||
queryHolders, insertKeys, insertValues, updateValues, duplicateKey []string,
|
||||
) (sqlStr string) {
|
||||
var (
|
||||
queryValueStr = strings.Join(queryValues, ",")
|
||||
unionValueStr = strings.Join(unionValues, " ")
|
||||
insertKeyStr = strings.Join(insertKeys, ",")
|
||||
insertValueStr = strings.Join(insertValues, ",")
|
||||
updateValueStr = strings.Join(updateValues, ",")
|
||||
pattern = gstr.Trim(`
|
||||
MERGE INTO %s T1 USING (SELECT %s FROM DUAL %s) T2 ON %s
|
||||
WHEN NOT MATCHED
|
||||
THEN
|
||||
INSERT(%s) VALUES (%s)
|
||||
WHEN MATCHED
|
||||
THEN
|
||||
UPDATE SET %s;
|
||||
COMMIT;
|
||||
`)
|
||||
queryHolderStr = strings.Join(queryHolders, ",")
|
||||
insertKeyStr = strings.Join(insertKeys, ",")
|
||||
insertValueStr = strings.Join(insertValues, ",")
|
||||
updateValueStr = strings.Join(updateValues, ",")
|
||||
duplicateKeyStr string
|
||||
pattern = gstr.Trim(`MERGE INTO %s T1 USING (SELECT %s FROM DUAL) T2 ON (%s) WHEN NOT MATCHED THEN INSERT(%s) VALUES (%s) WHEN MATCHED THEN UPDATE SET %s;`)
|
||||
)
|
||||
return fmt.Sprintf(
|
||||
pattern,
|
||||
table, queryValueStr, unionValueStr,
|
||||
fmt.Sprintf("(T1.%s = T2.%s)", duplicateKey, duplicateKey),
|
||||
insertKeyStr, insertValueStr, updateValueStr,
|
||||
|
||||
for index, keys := range duplicateKey {
|
||||
if index != 0 {
|
||||
duplicateKeyStr += " AND "
|
||||
}
|
||||
duplicateTmp := fmt.Sprintf("T1.%s = T2.%s", keys, keys)
|
||||
duplicateKeyStr += duplicateTmp
|
||||
}
|
||||
|
||||
return fmt.Sprintf(pattern,
|
||||
table,
|
||||
queryHolderStr,
|
||||
duplicateKeyStr,
|
||||
insertKeyStr,
|
||||
insertValueStr,
|
||||
updateValueStr,
|
||||
)
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
package dm_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -138,52 +139,53 @@ func Test_DB_Query(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestModelSave(t *testing.T) {
|
||||
table := "A_tables"
|
||||
createInitTable(table)
|
||||
table := createTable("test")
|
||||
defer dropTable(table)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := []User{
|
||||
{
|
||||
ID: 100,
|
||||
AccountName: "user_100",
|
||||
AttrIndex: 100,
|
||||
CreatedTime: time.Now(),
|
||||
},
|
||||
type User struct {
|
||||
Id int
|
||||
AccountName string
|
||||
AttrIndex int
|
||||
}
|
||||
_, err := db.Model(table).Data(data).Save()
|
||||
gtest.Assert(err, nil)
|
||||
var (
|
||||
user User
|
||||
count int
|
||||
result sql.Result
|
||||
err error
|
||||
)
|
||||
db.SetDebug(true)
|
||||
|
||||
data2 := []User{
|
||||
{
|
||||
ID: 101,
|
||||
AccountName: "user_101",
|
||||
},
|
||||
}
|
||||
_, err = db.Model(table).Data(&data2).Save()
|
||||
gtest.Assert(err, nil)
|
||||
result, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"accountName": "ac1",
|
||||
"attrIndex": 100,
|
||||
}).OnConflict("id").Save()
|
||||
|
||||
data3 := []User{
|
||||
{
|
||||
ID: 10,
|
||||
AccountName: "user_10",
|
||||
PwdReset: 10,
|
||||
},
|
||||
}
|
||||
_, err = db.Model(table).Save(data3)
|
||||
gtest.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
n, _ := result.RowsAffected()
|
||||
t.Assert(n, 1)
|
||||
|
||||
data4 := []User{
|
||||
{
|
||||
ID: 9,
|
||||
AccountName: "user_9",
|
||||
CreatedTime: time.Now(),
|
||||
},
|
||||
}
|
||||
_, err = db.Model(table).Save(&data4)
|
||||
gtest.Assert(err, nil)
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Id, 1)
|
||||
t.Assert(user.AccountName, "ac1")
|
||||
t.Assert(user.AttrIndex, 100)
|
||||
|
||||
// TODO:: Should be Supported 'Replace' Operation
|
||||
// _, err = db.Schema(TestDBName).Replace(ctx, "DoInsert", data, 10)
|
||||
// gtest.Assert(err, nil)
|
||||
_, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"accountName": "ac2",
|
||||
"attrIndex": 200,
|
||||
}).OnConflict("id").Save()
|
||||
t.AssertNil(err)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.AccountName, "ac2")
|
||||
t.Assert(user.AttrIndex, 200)
|
||||
|
||||
count, err = db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
})
|
||||
}
|
||||
|
||||
@ -198,7 +200,7 @@ func TestModelInsert(t *testing.T) {
|
||||
AccountName: fmt.Sprintf(`A%dtwo`, i),
|
||||
PwdReset: 0,
|
||||
AttrIndex: 99,
|
||||
// CreatedTime: time.Now(),
|
||||
CreatedTime: time.Now(),
|
||||
UpdatedTime: time.Now(),
|
||||
}
|
||||
// _, err := db.Schema(TestDBName).Model(table).Data(data).Insert()
|
||||
@ -214,7 +216,7 @@ func TestModelInsert(t *testing.T) {
|
||||
PwdReset: 1,
|
||||
CreatedTime: time.Now(),
|
||||
AttrIndex: 98,
|
||||
// UpdatedTime: time.Now(),
|
||||
UpdatedTime: time.Now(),
|
||||
}
|
||||
// _, err := db.Schema(TestDBName).Model(table).Data(data).Insert()
|
||||
_, err := db.Model(table).Data(&data).Insert()
|
||||
@ -232,6 +234,8 @@ func TestDBInsert(t *testing.T) {
|
||||
"ACCOUNT_NAME": fmt.Sprintf(`A%dthress`, i),
|
||||
"PWD_RESET": 3,
|
||||
"ATTR_INDEX": 98,
|
||||
"CREATED_TIME": gtime.Now(),
|
||||
"UPDATED_TIME": gtime.Now(),
|
||||
}
|
||||
_, err := db.Insert(ctx, table, &data)
|
||||
gtest.Assert(err, nil)
|
||||
@ -253,18 +257,21 @@ func Test_DB_Insert(t *testing.T) {
|
||||
table := "A_tables"
|
||||
createInitTable(table)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
timeNow := time.Now()
|
||||
// normal map
|
||||
_, err := db.Insert(ctx, table, g.Map{
|
||||
"ID": 1000,
|
||||
"ACCOUNT_NAME": "map1",
|
||||
"CREATED_TIME": gtime.Now(),
|
||||
"CREATED_TIME": timeNow,
|
||||
"UPDATED_TIME": timeNow,
|
||||
})
|
||||
t.AssertNil(err)
|
||||
|
||||
result, err := db.Insert(ctx, table, g.Map{
|
||||
"ID": "2000",
|
||||
"ACCOUNT_NAME": "map2",
|
||||
"CREATED_TIME": gtime.Now(),
|
||||
"CREATED_TIME": timeNow,
|
||||
"UPDATED_TIME": timeNow,
|
||||
})
|
||||
t.AssertNil(err)
|
||||
n, _ := result.RowsAffected()
|
||||
@ -273,7 +280,8 @@ func Test_DB_Insert(t *testing.T) {
|
||||
result, err = db.Insert(ctx, table, g.Map{
|
||||
"ID": 3000,
|
||||
"ACCOUNT_NAME": "map3",
|
||||
// "CREATED_TIME": gtime.Now(),
|
||||
"CREATED_TIME": timeNow,
|
||||
"UPDATED_TIME": timeNow,
|
||||
})
|
||||
t.AssertNil(err)
|
||||
n, _ = result.RowsAffected()
|
||||
@ -283,8 +291,8 @@ func Test_DB_Insert(t *testing.T) {
|
||||
result, err = db.Insert(ctx, table, User{
|
||||
ID: 4000,
|
||||
AccountName: "struct_4",
|
||||
// CreatedTime: timeStr,
|
||||
// UpdatedTime: timeStr,
|
||||
CreatedTime: timeNow,
|
||||
UpdatedTime: timeNow,
|
||||
})
|
||||
t.AssertNil(err)
|
||||
n, _ = result.RowsAffected()
|
||||
@ -299,12 +307,11 @@ func Test_DB_Insert(t *testing.T) {
|
||||
// t.Assert(one["CREATED_TIME"].GTime().String(), timeStr)
|
||||
|
||||
// *struct
|
||||
timeStr := time.Now()
|
||||
result, err = db.Insert(ctx, table, &User{
|
||||
ID: 5000,
|
||||
AccountName: "struct_5",
|
||||
CreatedTime: timeStr,
|
||||
// UpdatedTime: timeStr,
|
||||
CreatedTime: timeNow,
|
||||
UpdatedTime: timeNow,
|
||||
})
|
||||
t.AssertNil(err)
|
||||
n, _ = result.RowsAffected()
|
||||
@ -320,10 +327,14 @@ func Test_DB_Insert(t *testing.T) {
|
||||
g.Map{
|
||||
"ID": 6000,
|
||||
"ACCOUNT_NAME": "t6000",
|
||||
"CREATED_TIME": timeNow,
|
||||
"UPDATED_TIME": timeNow,
|
||||
},
|
||||
g.Map{
|
||||
"ID": 6001,
|
||||
"ACCOUNT_NAME": "t6001",
|
||||
"CREATED_TIME": timeNow,
|
||||
"UPDATED_TIME": timeNow,
|
||||
},
|
||||
})
|
||||
t.AssertNil(err)
|
||||
@ -345,12 +356,14 @@ func Test_DB_BatchInsert(t *testing.T) {
|
||||
{
|
||||
"ID": 400,
|
||||
"ACCOUNT_NAME": "list_400",
|
||||
// "CREATE_TIME": gtime.Now(),
|
||||
"CREATE_TIME": gtime.Now(),
|
||||
"UPDATED_TIME": gtime.Now(),
|
||||
},
|
||||
{
|
||||
"ID": 401,
|
||||
"ACCOUNT_NAME": "list_401",
|
||||
"CREATE_TIME": gtime.Now(),
|
||||
"UPDATED_TIME": gtime.Now(),
|
||||
},
|
||||
}, 1)
|
||||
t.AssertNil(err)
|
||||
@ -365,11 +378,13 @@ func Test_DB_BatchInsert(t *testing.T) {
|
||||
"ID": 500,
|
||||
"ACCOUNT_NAME": "500_batch_500",
|
||||
"CREATE_TIME": gtime.Now(),
|
||||
"UPDATED_TIME": gtime.Now(),
|
||||
},
|
||||
g.Map{
|
||||
"ID": 501,
|
||||
"ACCOUNT_NAME": "501_batch_501",
|
||||
// "CREATE_TIME": gtime.Now(),
|
||||
"CREATE_TIME": gtime.Now(),
|
||||
"UPDATED_TIME": gtime.Now(),
|
||||
},
|
||||
}, 1)
|
||||
t.AssertNil(err)
|
||||
@ -383,6 +398,7 @@ func Test_DB_BatchInsert(t *testing.T) {
|
||||
"ID": 600,
|
||||
"ACCOUNT_NAME": "600_batch_600",
|
||||
"CREATE_TIME": gtime.Now(),
|
||||
"UPDATED_TIME": gtime.Now(),
|
||||
})
|
||||
t.AssertNil(err)
|
||||
n, _ := result.RowsAffected()
|
||||
@ -394,11 +410,13 @@ func Test_DB_BatchInsert_Struct(t *testing.T) {
|
||||
// batch insert struct
|
||||
table := "A_tables"
|
||||
createInitTable(table)
|
||||
defer dropTable(table)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
user := &User{
|
||||
ID: 700,
|
||||
AccountName: "BatchInsert_Struct_700",
|
||||
// CreatedTime: time.Now(),
|
||||
CreatedTime: time.Now(),
|
||||
UpdatedTime: time.Now(),
|
||||
}
|
||||
result, err := db.Model(table).Insert(user)
|
||||
t.AssertNil(err)
|
||||
|
||||
@ -6,7 +6,7 @@ replace github.com/gogf/gf/v2 => ../../../
|
||||
|
||||
require (
|
||||
gitee.com/chunanyong/dm v1.8.12
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
@ -4,7 +4,7 @@ go 1.18
|
||||
|
||||
require (
|
||||
github.com/denisenkom/go-mssqldb v0.12.3
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
// Package mssql implements gdb.Driver, which supports operations for database MSSql.
|
||||
//
|
||||
// Note:
|
||||
// 1. It does not support Save/Replace features.
|
||||
// 1. It does not support Replace features.
|
||||
// 2. It does not support LastInsertId.
|
||||
package mssql
|
||||
|
||||
@ -15,8 +15,6 @@ import (
|
||||
_ "github.com/denisenkom/go-mssqldb"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/text/gregex"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
)
|
||||
|
||||
// Driver is the driver for SQL server database.
|
||||
@ -34,21 +32,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// formatSqlTmp formats sql template string into one line.
|
||||
func formatSqlTmp(sqlTmp string) string {
|
||||
var err error
|
||||
// format sql template string.
|
||||
sqlTmp, err = gregex.ReplaceString(`[\n\r\s]+`, " ", gstr.Trim(sqlTmp))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sqlTmp, err = gregex.ReplaceString(`\s{2,}`, " ", gstr.Trim(sqlTmp))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return sqlTmp
|
||||
}
|
||||
|
||||
// New create and returns a driver that implements gdb.Driver, which supports operations for Mssql.
|
||||
func New() gdb.Driver {
|
||||
return &Driver{}
|
||||
|
||||
@ -9,7 +9,6 @@ package mssql
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -27,7 +26,11 @@ WHERE TMP_.ROWNUMBER_ > %d AND TMP_.ROWNUMBER_ <= %d
|
||||
)
|
||||
|
||||
func init() {
|
||||
selectWithOrderSqlTmp = formatSqlTmp(selectWithOrderSqlTmp)
|
||||
var err error
|
||||
selectWithOrderSqlTmp, err = gdb.FormatMultiLineSqlToSingle(selectWithOrderSqlTmp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// DoFilter deals with the sql string before commits it to underlying sql driver.
|
||||
|
||||
@ -9,20 +9,21 @@ package mssql
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/container/gset"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
)
|
||||
|
||||
// DoInsert inserts or updates data forF given table.
|
||||
// DoInsert inserts or updates data for given table.
|
||||
func (d *Driver) DoInsert(ctx context.Context, link gdb.Link, table string, list gdb.List, option gdb.DoInsertOption) (result sql.Result, err error) {
|
||||
switch option.InsertOption {
|
||||
case gdb.InsertOptionSave:
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeNotSupported,
|
||||
`Save operation is not supported by mssql driver`,
|
||||
)
|
||||
return d.doSave(ctx, link, table, list, option)
|
||||
|
||||
case gdb.InsertOptionReplace:
|
||||
return nil, gerror.NewCode(
|
||||
@ -34,3 +35,116 @@ func (d *Driver) DoInsert(ctx context.Context, link gdb.Link, table string, list
|
||||
return d.Core.DoInsert(ctx, link, table, list, option)
|
||||
}
|
||||
}
|
||||
|
||||
// doSave support upsert for SQL server
|
||||
func (d *Driver) doSave(ctx context.Context,
|
||||
link gdb.Link, table string, list gdb.List, option gdb.DoInsertOption,
|
||||
) (result sql.Result, err error) {
|
||||
if len(option.OnConflict) == 0 {
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeMissingParameter, `Please specify conflict columns`,
|
||||
)
|
||||
}
|
||||
|
||||
if len(list) == 0 {
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeInvalidRequest, `Save operation list is empty by mssql driver`,
|
||||
)
|
||||
}
|
||||
|
||||
var (
|
||||
one = list[0]
|
||||
oneLen = len(one)
|
||||
charL, charR = d.GetChars()
|
||||
|
||||
conflictKeys = option.OnConflict
|
||||
conflictKeySet = gset.New(false)
|
||||
|
||||
// queryHolders: Handle data with Holder that need to be upsert
|
||||
// queryValues: Handle data that need to be upsert
|
||||
// insertKeys: Handle valid keys that need to be inserted
|
||||
// insertValues: Handle values that need to be inserted
|
||||
// updateValues: Handle values that need to be updated
|
||||
queryHolders = make([]string, oneLen)
|
||||
queryValues = make([]interface{}, oneLen)
|
||||
insertKeys = make([]string, oneLen)
|
||||
insertValues = make([]string, oneLen)
|
||||
updateValues []string
|
||||
)
|
||||
|
||||
// conflictKeys slice type conv to set type
|
||||
for _, conflictKey := range conflictKeys {
|
||||
conflictKeySet.Add(gstr.ToUpper(conflictKey))
|
||||
}
|
||||
|
||||
index := 0
|
||||
for key, value := range one {
|
||||
queryHolders[index] = "?"
|
||||
queryValues[index] = value
|
||||
insertKeys[index] = charL + key + charR
|
||||
insertValues[index] = "T2." + charL + key + charR
|
||||
|
||||
// filter conflict keys in updateValues.
|
||||
// And the key is not a soft created field.
|
||||
if !(conflictKeySet.Contains(key) || d.Core.IsSoftCreatedFieldName(key)) {
|
||||
updateValues = append(
|
||||
updateValues,
|
||||
fmt.Sprintf(`T1.%s = T2.%s`, charL+key+charR, charL+key+charR),
|
||||
)
|
||||
}
|
||||
index++
|
||||
}
|
||||
|
||||
batchResult := new(gdb.SqlResult)
|
||||
sqlStr := parseSqlForUpsert(table, queryHolders, insertKeys, insertValues, updateValues, conflictKeys)
|
||||
r, err := d.DoExec(ctx, link, sqlStr, queryValues...)
|
||||
if err != nil {
|
||||
return r, err
|
||||
}
|
||||
if n, err := r.RowsAffected(); err != nil {
|
||||
return r, err
|
||||
} else {
|
||||
batchResult.Result = r
|
||||
batchResult.Affected += n
|
||||
}
|
||||
return batchResult, nil
|
||||
}
|
||||
|
||||
// parseSqlForUpsert
|
||||
// MERGE INTO {{table}} T1
|
||||
// USING ( VALUES( {{queryHolders}}) T2 ({{insertKeyStr}})
|
||||
// ON (T1.{{duplicateKey}} = T2.{{duplicateKey}} AND ...)
|
||||
// WHEN NOT MATCHED THEN
|
||||
// INSERT {{insertKeys}} VALUES {{insertValues}}
|
||||
// WHEN MATCHED THEN
|
||||
// UPDATE SET {{updateValues}}
|
||||
func parseSqlForUpsert(table string,
|
||||
queryHolders, insertKeys, insertValues, updateValues, duplicateKey []string,
|
||||
) (sqlStr string) {
|
||||
var (
|
||||
queryHolderStr = strings.Join(queryHolders, ",")
|
||||
insertKeyStr = strings.Join(insertKeys, ",")
|
||||
insertValueStr = strings.Join(insertValues, ",")
|
||||
updateValueStr = strings.Join(updateValues, ",")
|
||||
duplicateKeyStr string
|
||||
pattern = gstr.Trim(`MERGE INTO %s T1 USING (VALUES(%s)) T2 (%s) ON (%s) WHEN NOT MATCHED THEN INSERT(%s) VALUES (%s) WHEN MATCHED THEN UPDATE SET %s;`)
|
||||
)
|
||||
|
||||
for index, keys := range duplicateKey {
|
||||
if index != 0 {
|
||||
duplicateKeyStr += " AND "
|
||||
}
|
||||
duplicateTmp := fmt.Sprintf("T1.%s = T2.%s", keys, keys)
|
||||
duplicateKeyStr += duplicateTmp
|
||||
}
|
||||
|
||||
return fmt.Sprintf(pattern,
|
||||
table,
|
||||
queryHolderStr,
|
||||
insertKeyStr,
|
||||
duplicateKeyStr,
|
||||
insertKeyStr,
|
||||
insertValueStr,
|
||||
updateValueStr,
|
||||
)
|
||||
}
|
||||
|
||||
@ -47,7 +47,11 @@ ORDER BY a.id,a.colorder
|
||||
)
|
||||
|
||||
func init() {
|
||||
tableFieldsSqlTmp = formatSqlTmp(tableFieldsSqlTmp)
|
||||
var err error
|
||||
tableFieldsSqlTmp, err = gdb.FormatMultiLineSqlToSingle(tableFieldsSqlTmp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// TableFields retrieves and returns the fields' information of specified table of current schema.
|
||||
|
||||
@ -217,7 +217,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
Nickname string `gconv:"nickname"`
|
||||
CreateTime *gtime.Time `json:"create_time"`
|
||||
}
|
||||
timeNow := gtime.Now()
|
||||
timeNow := gtime.New("2024-10-01 12:01:01")
|
||||
result, err = db.Insert(ctx, table, User{
|
||||
Id: 3,
|
||||
Passport: "user_3",
|
||||
@ -236,7 +236,8 @@ func Test_DB_Insert(t *testing.T) {
|
||||
t.Assert(one["PASSPORT"].String(), "user_3")
|
||||
t.Assert(one["PASSWORD"].String(), "25d55ad283aa400af464c76d713c07ad")
|
||||
t.Assert(one["NICKNAME"].String(), "name_3")
|
||||
t.Assert(one["CREATE_TIME"].GTime(), timeNow)
|
||||
t.AssertNE(one["CREATE_TIME"].GTime(), nil)
|
||||
t.AssertLT(timeNow.Sub(one["CREATE_TIME"].GTime()), 3)
|
||||
|
||||
// *struct
|
||||
timeNow = gtime.Now()
|
||||
|
||||
@ -24,10 +24,10 @@ import (
|
||||
"github.com/gogf/gf/v2/util/gutil"
|
||||
)
|
||||
|
||||
func TestPage(t *testing.T) {
|
||||
func Test_Page(t *testing.T) {
|
||||
table := createInitTable()
|
||||
defer dropTable(table)
|
||||
//db.SetDebug(true)
|
||||
// db.SetDebug(true)
|
||||
result, err := db.Model(table).Page(1, 2).Order("id").All()
|
||||
gtest.Assert(err, nil)
|
||||
fmt.Println("page:1--------", result)
|
||||
@ -2558,7 +2558,7 @@ func Test_Model_AllAndCount(t *testing.T) {
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
result, total, err := db.Model(table).Order("id").Limit(0, 3).AllAndCount(false)
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
|
||||
t.Assert(len(result), 3)
|
||||
t.Assert(total, TableSize)
|
||||
@ -2582,9 +2582,86 @@ func Test_Model_ScanAndCount(t *testing.T) {
|
||||
total := 0
|
||||
|
||||
err := db.Model(table).Order("id").Limit(0, 3).ScanAndCount(&users, &total, false)
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
|
||||
t.Assert(len(users), 3)
|
||||
t.Assert(total, TableSize)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Model_Save(t *testing.T) {
|
||||
table := createTable("test")
|
||||
defer dropTable(table)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
type User struct {
|
||||
Id int
|
||||
Passport string
|
||||
Password string
|
||||
NickName string
|
||||
CreatedAt *gtime.Time
|
||||
UpdatedAt *gtime.Time
|
||||
}
|
||||
var (
|
||||
user User
|
||||
count int
|
||||
result sql.Result
|
||||
err error
|
||||
)
|
||||
|
||||
result, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "p1",
|
||||
"password": "15d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "n1",
|
||||
}).OnConflict("id").Save()
|
||||
|
||||
t.AssertNil(err)
|
||||
n, _ := result.RowsAffected()
|
||||
t.Assert(n, 1)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Id, 1)
|
||||
t.Assert(user.Passport, "p1")
|
||||
t.Assert(user.Password, "15d55ad283aa400af464c76d713c07ad")
|
||||
t.Assert(user.NickName, "n1")
|
||||
|
||||
// Sleep 1 second to make sure the updated time is different.
|
||||
time.Sleep(1 * time.Second)
|
||||
_, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "p1",
|
||||
"password": "25d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "n2",
|
||||
}).OnConflict("id").Save()
|
||||
t.AssertNil(err)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Passport, "p1")
|
||||
t.Assert(user.Password, "25d55ad283aa400af464c76d713c07ad")
|
||||
t.Assert(user.NickName, "n2")
|
||||
// check created_at not equal to updated_at
|
||||
t.AssertNE(user.CreatedAt, user.UpdatedAt)
|
||||
|
||||
count, err = db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Model_Replace(t *testing.T) {
|
||||
table := createTable()
|
||||
defer dropTable(table)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
_, err := db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "t11",
|
||||
"password": "25d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "T11",
|
||||
"create_time": "2018-10-24 10:00:00",
|
||||
}).Replace()
|
||||
t.Assert(err, "Replace operation is not supported by mssql driver")
|
||||
})
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ go 1.18
|
||||
|
||||
require (
|
||||
github.com/go-sql-driver/mysql v1.7.1
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
@ -14,6 +14,36 @@ import (
|
||||
"github.com/gogf/gf/v2/util/gutil"
|
||||
)
|
||||
|
||||
var (
|
||||
tableFieldsSqlByMariadb = `
|
||||
SELECT
|
||||
c.COLUMN_NAME AS 'Field',
|
||||
( CASE WHEN ch.CHECK_CLAUSE LIKE 'json_valid%%' THEN 'json' ELSE c.COLUMN_TYPE END ) AS 'Type',
|
||||
c.COLLATION_NAME AS 'Collation',
|
||||
c.IS_NULLABLE AS 'Null',
|
||||
c.COLUMN_KEY AS 'Key',
|
||||
( CASE WHEN c.COLUMN_DEFAULT = 'NULL' OR c.COLUMN_DEFAULT IS NULL THEN NULL ELSE c.COLUMN_DEFAULT END) AS 'Default',
|
||||
c.EXTRA AS 'Extra',
|
||||
c.PRIVILEGES AS 'Privileges',
|
||||
c.COLUMN_COMMENT AS 'Comment'
|
||||
FROM
|
||||
information_schema.COLUMNS AS c
|
||||
LEFT JOIN information_schema.CHECK_CONSTRAINTS AS ch ON c.TABLE_NAME = ch.TABLE_NAME
|
||||
AND c.COLUMN_NAME = ch.CONSTRAINT_NAME
|
||||
WHERE
|
||||
c.TABLE_SCHEMA = '%s'
|
||||
AND c.TABLE_NAME = '%s'
|
||||
ORDER BY c.ORDINAL_POSITION`
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
tableFieldsSqlByMariadb, err = gdb.FormatMultiLineSqlToSingle(tableFieldsSqlByMariadb)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// TableFields retrieves and returns the fields' information of specified table of current
|
||||
// schema.
|
||||
//
|
||||
@ -28,16 +58,25 @@ import (
|
||||
// process restarts.
|
||||
func (d *Driver) TableFields(ctx context.Context, table string, schema ...string) (fields map[string]*gdb.TableField, err error) {
|
||||
var (
|
||||
result gdb.Result
|
||||
link gdb.Link
|
||||
usedSchema = gutil.GetOrDefaultStr(d.GetSchema(), schema...)
|
||||
result gdb.Result
|
||||
link gdb.Link
|
||||
usedSchema = gutil.GetOrDefaultStr(d.GetSchema(), schema...)
|
||||
tableFieldsSql string
|
||||
)
|
||||
if link, err = d.SlaveLink(usedSchema); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbType := d.GetConfig().Type
|
||||
switch dbType {
|
||||
case "mariadb":
|
||||
tableFieldsSql = fmt.Sprintf(tableFieldsSqlByMariadb, usedSchema, table)
|
||||
default:
|
||||
tableFieldsSql = fmt.Sprintf(`SHOW FULL COLUMNS FROM %s`, d.QuoteWord(table))
|
||||
}
|
||||
|
||||
result, err = d.DoSelect(
|
||||
ctx, link,
|
||||
fmt.Sprintf(`SHOW FULL COLUMNS FROM %s`, d.QuoteWord(table)),
|
||||
tableFieldsSql,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -127,7 +127,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
Nickname string `gconv:"nickname"`
|
||||
CreateTime string `json:"create_time"`
|
||||
}
|
||||
timeStr := gtime.Now().String()
|
||||
timeStr := gtime.New("2024-10-01 12:01:01").String()
|
||||
result, err = db.Insert(ctx, table, User{
|
||||
Id: 3,
|
||||
Passport: "user_3",
|
||||
@ -149,7 +149,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
t.Assert(one["create_time"].GTime().String(), timeStr)
|
||||
|
||||
// *struct
|
||||
timeStr = gtime.Now().String()
|
||||
timeStr = gtime.New("2024-10-01 12:01:01").String()
|
||||
result, err = db.Insert(ctx, table, &User{
|
||||
Id: 4,
|
||||
Passport: "t4",
|
||||
@ -170,7 +170,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
t.Assert(one["create_time"].GTime().String(), timeStr)
|
||||
|
||||
// batch with Insert
|
||||
timeStr = gtime.Now().String()
|
||||
timeStr = gtime.New("2024-10-01 12:01:01").String()
|
||||
r, err := db.Insert(ctx, table, g.Slice{
|
||||
g.Map{
|
||||
"id": 200,
|
||||
@ -487,7 +487,7 @@ func Test_DB_Save(t *testing.T) {
|
||||
defer dropTable(table)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
timeStr := gtime.Now().String()
|
||||
timeStr := gtime.New("2024-10-01 12:01:01").String()
|
||||
_, err := db.Save(ctx, table, g.Map{
|
||||
"id": 1,
|
||||
"passport": "t1",
|
||||
@ -512,7 +512,7 @@ func Test_DB_Replace(t *testing.T) {
|
||||
defer dropTable(table)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
timeStr := gtime.Now().String()
|
||||
timeStr := gtime.New("2024-10-01 12:01:01").String()
|
||||
_, err := db.Replace(ctx, table, g.Map{
|
||||
"id": 1,
|
||||
"passport": "t1",
|
||||
|
||||
@ -3646,7 +3646,7 @@ func Test_Model_OnDuplicate(t *testing.T) {
|
||||
table := createInitTable()
|
||||
defer dropTable(table)
|
||||
|
||||
// string.
|
||||
// string type 1.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
@ -3664,6 +3664,24 @@ func Test_Model_OnDuplicate(t *testing.T) {
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// string type 2.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnDuplicate("passport", "password").Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// slice.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
@ -3729,7 +3747,7 @@ func Test_Model_OnDuplicateEx(t *testing.T) {
|
||||
table := createInitTable()
|
||||
defer dropTable(table)
|
||||
|
||||
// string.
|
||||
// string type 1.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
@ -3747,6 +3765,24 @@ func Test_Model_OnDuplicateEx(t *testing.T) {
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// string type 2.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnDuplicateEx("nickname", "create_time").Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// slice.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
@ -4633,13 +4669,13 @@ func TestResult_Structs1(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
r := gdb.Result{
|
||||
gdb.Record{"id": gvar.New(nil), "name": gvar.New("john")},
|
||||
gdb.Record{"id": gvar.New(nil), "name": gvar.New("smith")},
|
||||
gdb.Record{"id": gvar.New(1), "name": gvar.New("smith")},
|
||||
}
|
||||
array := make([]*B, 2)
|
||||
err := r.Structs(&array)
|
||||
t.AssertNil(err)
|
||||
t.Assert(array[0].Id, 0)
|
||||
t.Assert(array[1].Id, 0)
|
||||
t.Assert(array[1].Id, 1)
|
||||
t.Assert(array[0].Name, "john")
|
||||
t.Assert(array[1].Name, "smith")
|
||||
})
|
||||
|
||||
@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/oracle/v2
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
github.com/sijms/go-ora/v2 v2.7.10
|
||||
)
|
||||
|
||||
|
||||
@ -13,8 +13,6 @@ package oracle
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/text/gregex"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
)
|
||||
|
||||
// Driver is the driver for oracle database.
|
||||
@ -32,21 +30,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// formatSqlTmp formats sql template string into one line.
|
||||
func formatSqlTmp(sqlTmp string) string {
|
||||
var err error
|
||||
// format sql template string.
|
||||
sqlTmp, err = gregex.ReplaceString(`[\n\r\s]+`, " ", gstr.Trim(sqlTmp))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sqlTmp, err = gregex.ReplaceString(`\s{2,}`, " ", gstr.Trim(sqlTmp))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return sqlTmp
|
||||
}
|
||||
|
||||
// New create and returns a driver that implements gdb.Driver, which supports operations for Oracle.
|
||||
func New() gdb.Driver {
|
||||
return &Driver{}
|
||||
|
||||
@ -27,7 +27,11 @@ SELECT * FROM (
|
||||
)
|
||||
|
||||
func init() {
|
||||
newSqlReplacementTmp = formatSqlTmp(newSqlReplacementTmp)
|
||||
var err error
|
||||
newSqlReplacementTmp, err = gdb.FormatMultiLineSqlToSingle(newSqlReplacementTmp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// DoFilter deals with the sql string before commits it to underlying sql driver.
|
||||
|
||||
@ -12,6 +12,9 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/container/gset"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
@ -24,10 +27,7 @@ func (d *Driver) DoInsert(
|
||||
) (result sql.Result, err error) {
|
||||
switch option.InsertOption {
|
||||
case gdb.InsertOptionSave:
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeNotSupported,
|
||||
`Save operation is not supported by oracle driver`,
|
||||
)
|
||||
return d.doSave(ctx, link, table, list, option)
|
||||
|
||||
case gdb.InsertOptionReplace:
|
||||
return nil, gerror.NewCode(
|
||||
@ -93,3 +93,116 @@ func (d *Driver) DoInsert(
|
||||
}
|
||||
return batchResult, nil
|
||||
}
|
||||
|
||||
// doSave support upsert for Oracle
|
||||
func (d *Driver) doSave(ctx context.Context,
|
||||
link gdb.Link, table string, list gdb.List, option gdb.DoInsertOption,
|
||||
) (result sql.Result, err error) {
|
||||
if len(option.OnConflict) == 0 {
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeMissingParameter, `Please specify conflict columns`,
|
||||
)
|
||||
}
|
||||
|
||||
if len(list) == 0 {
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeInvalidRequest, `Save operation list is empty by oracle driver`,
|
||||
)
|
||||
}
|
||||
|
||||
var (
|
||||
one = list[0]
|
||||
oneLen = len(one)
|
||||
charL, charR = d.GetChars()
|
||||
|
||||
conflictKeys = option.OnConflict
|
||||
conflictKeySet = gset.New(false)
|
||||
|
||||
// queryHolders: Handle data with Holder that need to be upsert
|
||||
// queryValues: Handle data that need to be upsert
|
||||
// insertKeys: Handle valid keys that need to be inserted
|
||||
// insertValues: Handle values that need to be inserted
|
||||
// updateValues: Handle values that need to be updated
|
||||
queryHolders = make([]string, oneLen)
|
||||
queryValues = make([]interface{}, oneLen)
|
||||
insertKeys = make([]string, oneLen)
|
||||
insertValues = make([]string, oneLen)
|
||||
updateValues []string
|
||||
)
|
||||
|
||||
// conflictKeys slice type conv to set type
|
||||
for _, conflictKey := range conflictKeys {
|
||||
conflictKeySet.Add(gstr.ToUpper(conflictKey))
|
||||
}
|
||||
|
||||
index := 0
|
||||
for key, value := range one {
|
||||
keyWithChar := charL + key + charR
|
||||
queryHolders[index] = fmt.Sprintf("? AS %s", keyWithChar)
|
||||
queryValues[index] = value
|
||||
insertKeys[index] = keyWithChar
|
||||
insertValues[index] = fmt.Sprintf("T2.%s", keyWithChar)
|
||||
|
||||
// filter conflict keys in updateValues.
|
||||
// And the key is not a soft created field.
|
||||
if !(conflictKeySet.Contains(key) || d.Core.IsSoftCreatedFieldName(key)) {
|
||||
updateValues = append(
|
||||
updateValues,
|
||||
fmt.Sprintf(`T1.%s = T2.%s`, keyWithChar, keyWithChar),
|
||||
)
|
||||
}
|
||||
index++
|
||||
}
|
||||
|
||||
batchResult := new(gdb.SqlResult)
|
||||
sqlStr := parseSqlForUpsert(table, queryHolders, insertKeys, insertValues, updateValues, conflictKeys)
|
||||
r, err := d.DoExec(ctx, link, sqlStr, queryValues...)
|
||||
if err != nil {
|
||||
return r, err
|
||||
}
|
||||
if n, err := r.RowsAffected(); err != nil {
|
||||
return r, err
|
||||
} else {
|
||||
batchResult.Result = r
|
||||
batchResult.Affected += n
|
||||
}
|
||||
return batchResult, nil
|
||||
}
|
||||
|
||||
// parseSqlForUpsert
|
||||
// MERGE INTO {{table}} T1
|
||||
// USING ( SELECT {{queryHolders}} FROM DUAL T2
|
||||
// ON (T1.{{duplicateKey}} = T2.{{duplicateKey}} AND ...)
|
||||
// WHEN NOT MATCHED THEN
|
||||
// INSERT {{insertKeys}} VALUES {{insertValues}}
|
||||
// WHEN MATCHED THEN
|
||||
// UPDATE SET {{updateValues}}
|
||||
func parseSqlForUpsert(table string,
|
||||
queryHolders, insertKeys, insertValues, updateValues, duplicateKey []string,
|
||||
) (sqlStr string) {
|
||||
var (
|
||||
queryHolderStr = strings.Join(queryHolders, ",")
|
||||
insertKeyStr = strings.Join(insertKeys, ",")
|
||||
insertValueStr = strings.Join(insertValues, ",")
|
||||
updateValueStr = strings.Join(updateValues, ",")
|
||||
duplicateKeyStr string
|
||||
pattern = gstr.Trim(`MERGE INTO %s T1 USING (SELECT %s FROM DUAL) T2 ON (%s) WHEN NOT MATCHED THEN INSERT(%s) VALUES (%s) WHEN MATCHED THEN UPDATE SET %s`)
|
||||
)
|
||||
|
||||
for index, keys := range duplicateKey {
|
||||
if index != 0 {
|
||||
duplicateKeyStr += " AND "
|
||||
}
|
||||
duplicateTmp := fmt.Sprintf("T1.%s = T2.%s", keys, keys)
|
||||
duplicateKeyStr += duplicateTmp
|
||||
}
|
||||
|
||||
return fmt.Sprintf(pattern,
|
||||
table,
|
||||
queryHolderStr,
|
||||
duplicateKeyStr,
|
||||
insertKeyStr,
|
||||
insertValueStr,
|
||||
updateValueStr,
|
||||
)
|
||||
}
|
||||
|
||||
@ -8,13 +8,14 @@ package oracle
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"strings"
|
||||
|
||||
gora "github.com/sijms/go-ora/v2"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/text/gregex"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
@ -45,12 +46,13 @@ func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) {
|
||||
}
|
||||
} else {
|
||||
if config.Extra != "" {
|
||||
var extraMap map[string]interface{}
|
||||
if extraMap, err = gstr.Parse(config.Extra); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for k, v := range extraMap {
|
||||
options[k] = gconv.String(v)
|
||||
// fix #3226
|
||||
list := strings.Split(config.Extra, "&")
|
||||
for _, v := range list {
|
||||
kv := strings.Split(v, "=")
|
||||
if len(kv) == 2 {
|
||||
options[kv[0]] = kv[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
source = gora.BuildUrl(
|
||||
|
||||
@ -29,7 +29,11 @@ FROM USER_TAB_COLUMNS WHERE TABLE_NAME = '%s' ORDER BY COLUMN_ID
|
||||
)
|
||||
|
||||
func init() {
|
||||
tableFieldsSqlTmp = formatSqlTmp(tableFieldsSqlTmp)
|
||||
var err error
|
||||
tableFieldsSqlTmp, err = gdb.FormatMultiLineSqlToSingle(tableFieldsSqlTmp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// TableFields retrieves and returns the fields' information of specified table of current schema.
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
@ -18,7 +19,7 @@ import (
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
)
|
||||
|
||||
func TestTables(t *testing.T) {
|
||||
func Test_Tables(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
tables := []string{"t_user1", "pop", "haha"}
|
||||
|
||||
@ -59,7 +60,7 @@ func TestTables(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestTableFields(t *testing.T) {
|
||||
func Test_Table_Fields(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
createTable("t_user")
|
||||
defer dropTable("t_user")
|
||||
@ -106,7 +107,7 @@ func TestTableFields(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestDoInsert(t *testing.T) {
|
||||
func Test_Do_Insert(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
createTable("t_user")
|
||||
defer dropTable("t_user")
|
||||
@ -218,7 +219,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
Salary float64 `gconv:"SALARY"`
|
||||
CreateTime string `json:"CREATE_TIME"`
|
||||
}
|
||||
timeStr := gtime.Now().String()
|
||||
timeStr := gtime.New("2024-10-01 12:01:01").String()
|
||||
result, err = db.Insert(ctx, table, User{
|
||||
Id: 3,
|
||||
Passport: "user_3",
|
||||
@ -242,7 +243,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
t.Assert(one["CREATE_TIME"].GTime().String(), timeStr)
|
||||
|
||||
// *struct
|
||||
timeStr = gtime.Now().String()
|
||||
timeStr = gtime.New("2024-10-01 12:01:01").String()
|
||||
result, err = db.Insert(ctx, table, &User{
|
||||
Id: 4,
|
||||
Passport: "t4",
|
||||
@ -265,7 +266,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
t.Assert(one["CREATE_TIME"].GTime().String(), timeStr)
|
||||
|
||||
// batch with Insert
|
||||
timeStr = gtime.Now().String()
|
||||
timeStr = gtime.New("2024-10-01 12:01:01").String()
|
||||
r, err := db.Insert(ctx, table, g.Slice{
|
||||
g.Map{
|
||||
"ID": 200,
|
||||
@ -692,3 +693,22 @@ func Test_Empty_Slice_Argument(t *testing.T) {
|
||||
t.Assert(len(result), 0)
|
||||
})
|
||||
}
|
||||
|
||||
// fix #3226
|
||||
func Test_Extra(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
nodeLink := gdb.ConfigNode{
|
||||
Type: TestDbType,
|
||||
Name: TestDbName,
|
||||
Link: fmt.Sprintf("%s:%s:%s@tcp(%s:%s)/%s?lob fetch=post&SSL VERIFY=false",
|
||||
TestDbType, TestDbUser, TestDbPass, TestDbIP, TestDbPort, TestDbName,
|
||||
),
|
||||
}
|
||||
if r, err := gdb.New(nodeLink); err != nil {
|
||||
gtest.Fatal(err)
|
||||
} else {
|
||||
err1 := r.PingMaster()
|
||||
t.Assert(err1, nil)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ func createTable(table ...string) (name string) {
|
||||
gtest.Fatal(err)
|
||||
}
|
||||
|
||||
//db.Schema("test")
|
||||
// db.Schema("test")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ func Test_Model_RightJoin(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestPage(t *testing.T) {
|
||||
func Test_Page(t *testing.T) {
|
||||
table := createInitTable()
|
||||
defer dropTable(table)
|
||||
result, err := db.Model(table).Page(1, 2).Order("ID").All()
|
||||
@ -162,7 +162,6 @@ func TestPage(t *testing.T) {
|
||||
func Test_Model_Insert(t *testing.T) {
|
||||
table := createTable()
|
||||
defer dropTable(table)
|
||||
// db.SetDebug(true)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
user := db.Model(table)
|
||||
result, err := user.Data(g.Map{
|
||||
@ -1101,6 +1100,83 @@ func Test_Model_WhereOrNotLike(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Model_Save(t *testing.T) {
|
||||
table := createTable("test")
|
||||
defer dropTable(table)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
type User struct {
|
||||
Id int
|
||||
Passport string
|
||||
Password string
|
||||
NickName string
|
||||
CreateTime *gtime.Time
|
||||
}
|
||||
var (
|
||||
user User
|
||||
count int
|
||||
result sql.Result
|
||||
createTime = gtime.Now().Format("Y-m-d")
|
||||
err error
|
||||
)
|
||||
|
||||
result, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "p1",
|
||||
"password": "15d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "n1",
|
||||
"create_time": createTime,
|
||||
}).OnConflict("id").Save()
|
||||
|
||||
t.AssertNil(err)
|
||||
n, _ := result.RowsAffected()
|
||||
t.Assert(n, 1)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Id, 1)
|
||||
t.Assert(user.Passport, "p1")
|
||||
t.Assert(user.Password, "15d55ad283aa400af464c76d713c07ad")
|
||||
t.Assert(user.NickName, "n1")
|
||||
t.Assert(user.CreateTime.Format("Y-m-d"), createTime)
|
||||
|
||||
_, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "p1",
|
||||
"password": "25d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "n2",
|
||||
"create_time": createTime,
|
||||
}).OnConflict("id").Save()
|
||||
t.AssertNil(err)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Passport, "p1")
|
||||
t.Assert(user.Password, "25d55ad283aa400af464c76d713c07ad")
|
||||
t.Assert(user.NickName, "n2")
|
||||
t.Assert(user.CreateTime.Format("Y-m-d"), createTime)
|
||||
|
||||
count, err = db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Model_Replace(t *testing.T) {
|
||||
table := createTable()
|
||||
defer dropTable(table)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
_, err := db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "t11",
|
||||
"password": "25d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "T11",
|
||||
"create_time": "2018-10-24 10:00:00",
|
||||
}).Replace()
|
||||
t.Assert(err, "Replace operation is not supported by oracle driver")
|
||||
})
|
||||
}
|
||||
|
||||
/* not support the "AS"
|
||||
func Test_Model_Raw(t *testing.T) {
|
||||
table := createInitTable()
|
||||
|
||||
@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/pgsql/v2
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
github.com/lib/pq v1.10.9
|
||||
)
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
// Package pgsql implements gdb.Driver, which supports operations for database PostgreSQL.
|
||||
//
|
||||
// Note:
|
||||
// 1. It does not support Save/Replace features.
|
||||
// 1. It does not support Replace features.
|
||||
// 2. It does not support Insert Ignore features.
|
||||
package pgsql
|
||||
|
||||
@ -16,8 +16,6 @@ import (
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/text/gregex"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
)
|
||||
|
||||
// Driver is the driver for postgresql database.
|
||||
@ -37,21 +35,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// formatSqlTmp formats sql template string into one line.
|
||||
func formatSqlTmp(sqlTmp string) string {
|
||||
var err error
|
||||
// format sql template string.
|
||||
sqlTmp, err = gregex.ReplaceString(`[\n\r\s]+`, " ", gstr.Trim(sqlTmp))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sqlTmp, err = gregex.ReplaceString(`\s{2,}`, " ", gstr.Trim(sqlTmp))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return sqlTmp
|
||||
}
|
||||
|
||||
// New create and returns a driver that implements gdb.Driver, which supports operations for PostgreSql.
|
||||
func New() gdb.Driver {
|
||||
return &Driver{}
|
||||
|
||||
@ -15,15 +15,9 @@ import (
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// DoInsert inserts or updates data forF given table.
|
||||
// DoInsert inserts or updates data for given table.
|
||||
func (d *Driver) DoInsert(ctx context.Context, link gdb.Link, table string, list gdb.List, option gdb.DoInsertOption) (result sql.Result, err error) {
|
||||
switch option.InsertOption {
|
||||
case gdb.InsertOptionSave:
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeNotSupported,
|
||||
`Save operation is not supported by pgsql driver`,
|
||||
)
|
||||
|
||||
case gdb.InsertOptionReplace:
|
||||
return nil, gerror.NewCode(
|
||||
gcode.CodeNotSupported,
|
||||
|
||||
71
contrib/drivers/pgsql/pgsql_format_upsert.go
Normal file
71
contrib/drivers/pgsql/pgsql_format_upsert.go
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package pgsql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
// FormatUpsert returns SQL clause of type upsert for PgSQL.
|
||||
// For example: ON CONFLICT (id) DO UPDATE SET ...
|
||||
func (d *Driver) FormatUpsert(columns []string, list gdb.List, option gdb.DoInsertOption) (string, error) {
|
||||
if len(option.OnConflict) == 0 {
|
||||
return "", gerror.NewCode(
|
||||
gcode.CodeMissingParameter, `Please specify conflict columns`,
|
||||
)
|
||||
}
|
||||
|
||||
var onDuplicateStr string
|
||||
if option.OnDuplicateStr != "" {
|
||||
onDuplicateStr = option.OnDuplicateStr
|
||||
} else if len(option.OnDuplicateMap) > 0 {
|
||||
for k, v := range option.OnDuplicateMap {
|
||||
if len(onDuplicateStr) > 0 {
|
||||
onDuplicateStr += ","
|
||||
}
|
||||
switch v.(type) {
|
||||
case gdb.Raw, *gdb.Raw:
|
||||
onDuplicateStr += fmt.Sprintf(
|
||||
"%s=%s",
|
||||
d.Core.QuoteWord(k),
|
||||
v,
|
||||
)
|
||||
default:
|
||||
onDuplicateStr += fmt.Sprintf(
|
||||
"%s=EXCLUDED.%s",
|
||||
d.Core.QuoteWord(k),
|
||||
d.Core.QuoteWord(gconv.String(v)),
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, column := range columns {
|
||||
// If it's SAVE operation, do not automatically update the creating time.
|
||||
if d.Core.IsSoftCreatedFieldName(column) {
|
||||
continue
|
||||
}
|
||||
if len(onDuplicateStr) > 0 {
|
||||
onDuplicateStr += ","
|
||||
}
|
||||
onDuplicateStr += fmt.Sprintf(
|
||||
"%s=EXCLUDED.%s",
|
||||
d.Core.QuoteWord(column),
|
||||
d.Core.QuoteWord(column),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
conflictKeys := gstr.Join(option.OnConflict, ",")
|
||||
|
||||
return fmt.Sprintf("ON CONFLICT (%s) DO UPDATE SET ", conflictKeys) + onDuplicateStr, nil
|
||||
}
|
||||
@ -17,7 +17,7 @@ import (
|
||||
var (
|
||||
tableFieldsSqlTmp = `
|
||||
SELECT a.attname AS field, t.typname AS type,a.attnotnull as null,
|
||||
(case when d.contype is not null then 'pri' else '' end) as key
|
||||
(case when d.contype = 'p' then 'pri' when d.contype = 'u' then 'uni' else '' end) as key
|
||||
,ic.column_default as default_value,b.description as comment
|
||||
,coalesce(character_maximum_length, numeric_precision, -1) as length
|
||||
,numeric_scale as scale
|
||||
@ -32,7 +32,11 @@ ORDER BY a.attnum`
|
||||
)
|
||||
|
||||
func init() {
|
||||
tableFieldsSqlTmp = formatSqlTmp(tableFieldsSqlTmp)
|
||||
var err error
|
||||
tableFieldsSqlTmp, err = gdb.FormatMultiLineSqlToSingle(tableFieldsSqlTmp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// TableFields retrieves and returns the fields' information of specified table of current schema.
|
||||
|
||||
@ -35,7 +35,11 @@ ORDER BY
|
||||
)
|
||||
|
||||
func init() {
|
||||
tablesSqlTmp = formatSqlTmp(tablesSqlTmp)
|
||||
var err error
|
||||
tablesSqlTmp, err = gdb.FormatMultiLineSqlToSingle(tablesSqlTmp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Tables retrieves and returns the tables of current schema.
|
||||
|
||||
@ -78,12 +78,12 @@ func createTableWithDb(db gdb.DB, table ...string) (name string) {
|
||||
|
||||
if _, err := db.Exec(ctx, fmt.Sprintf(`
|
||||
CREATE TABLE %s (
|
||||
id bigserial NOT NULL,
|
||||
passport varchar(45) NOT NULL,
|
||||
password varchar(32) NOT NULL,
|
||||
nickname varchar(45) NOT NULL,
|
||||
create_time timestamp NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
id bigserial NOT NULL,
|
||||
passport varchar(45) NOT NULL,
|
||||
password varchar(32) NOT NULL,
|
||||
nickname varchar(45) NOT NULL,
|
||||
create_time timestamp NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ;`, name,
|
||||
)); err != nil {
|
||||
gtest.Fatal(err)
|
||||
|
||||
75
contrib/drivers/pgsql/pgsql_z_unit_issue_test.go
Normal file
75
contrib/drivers/pgsql/pgsql_z_unit_issue_test.go
Normal file
@ -0,0 +1,75 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package pgsql_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"testing"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
)
|
||||
|
||||
// https://github.com/gogf/gf/issues/3330
|
||||
func Test_Issue3330(t *testing.T) {
|
||||
var (
|
||||
table = fmt.Sprintf(`%s_%d`, TablePrefix+"test", gtime.TimestampNano())
|
||||
uniqueName = fmt.Sprintf(`%s_%d`, TablePrefix+"test_unique", gtime.TimestampNano())
|
||||
)
|
||||
if _, err := db.Exec(ctx, fmt.Sprintf(`
|
||||
CREATE TABLE %s (
|
||||
id bigserial NOT NULL,
|
||||
passport varchar(45) NOT NULL,
|
||||
password varchar(32) NOT NULL,
|
||||
nickname varchar(45) NOT NULL,
|
||||
create_time timestamp NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
CONSTRAINT %s unique ("password")
|
||||
) ;`, table, uniqueName,
|
||||
)); err != nil {
|
||||
gtest.Fatal(err)
|
||||
}
|
||||
defer dropTable(table)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
list []map[string]interface{}
|
||||
one gdb.Record
|
||||
err error
|
||||
)
|
||||
|
||||
fields, err := db.TableFields(ctx, table)
|
||||
t.AssertNil(err)
|
||||
|
||||
t.Assert(fields["id"].Key, "pri")
|
||||
t.Assert(fields["password"].Key, "uni")
|
||||
|
||||
for i := 1; i <= 10; i++ {
|
||||
list = append(list, g.Map{
|
||||
"id": i,
|
||||
"passport": fmt.Sprintf("p%d", i),
|
||||
"password": fmt.Sprintf("pw%d", i),
|
||||
"nickname": fmt.Sprintf("n%d", i),
|
||||
"create_time": "2016-06-01 00:00:00",
|
||||
})
|
||||
}
|
||||
|
||||
_, err = db.Model(table).Data(list).Insert()
|
||||
t.AssertNil(err)
|
||||
|
||||
for i := 1; i <= 10; i++ {
|
||||
one, err = db.Model(table).WherePri(i).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["id"], list[i-1]["id"])
|
||||
t.Assert(one["passport"], list[i-1]["passport"])
|
||||
t.Assert(one["password"], list[i-1]["password"])
|
||||
t.Assert(one["nickname"], list[i-1]["nickname"])
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -7,8 +7,11 @@
|
||||
package pgsql_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
@ -258,14 +261,58 @@ func Test_Model_Save(t *testing.T) {
|
||||
table := createTable()
|
||||
defer dropTable(table)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
_, err := db.Model(table).Data(g.Map{
|
||||
type User struct {
|
||||
Id int
|
||||
Passport string
|
||||
Password string
|
||||
NickName string
|
||||
CreateTime *gtime.Time
|
||||
}
|
||||
var (
|
||||
user User
|
||||
count int
|
||||
result sql.Result
|
||||
err error
|
||||
)
|
||||
|
||||
result, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "t111",
|
||||
"password": "25d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "T111",
|
||||
"create_time": "2018-10-24 10:00:00",
|
||||
}).Save()
|
||||
t.Assert(err, "Save operation is not supported by pgsql driver")
|
||||
"passport": "p1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": CreateTime,
|
||||
}).OnConflict("id").Save()
|
||||
t.AssertNil(err)
|
||||
n, _ := result.RowsAffected()
|
||||
t.Assert(n, 1)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Id, 1)
|
||||
t.Assert(user.Passport, "p1")
|
||||
t.Assert(user.Password, "pw1")
|
||||
t.Assert(user.NickName, "n1")
|
||||
t.Assert(user.CreateTime.String(), CreateTime)
|
||||
|
||||
_, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "p1",
|
||||
"password": "pw2",
|
||||
"nickname": "n2",
|
||||
"create_time": CreateTime,
|
||||
}).OnConflict("id").Save()
|
||||
t.AssertNil(err)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Passport, "p1")
|
||||
t.Assert(user.Password, "pw2")
|
||||
t.Assert(user.NickName, "n2")
|
||||
t.Assert(user.CreateTime.String(), CreateTime)
|
||||
|
||||
count, err = db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
})
|
||||
}
|
||||
|
||||
@ -284,3 +331,259 @@ func Test_Model_Replace(t *testing.T) {
|
||||
t.Assert(err, "Replace operation is not supported by pgsql driver")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Model_OnConflict(t *testing.T) {
|
||||
var (
|
||||
table = fmt.Sprintf(`%s_%d`, TablePrefix+"test", gtime.TimestampNano())
|
||||
uniqueName = fmt.Sprintf(`%s_%d`, TablePrefix+"test_unique", gtime.TimestampNano())
|
||||
)
|
||||
if _, err := db.Exec(ctx, fmt.Sprintf(`
|
||||
CREATE TABLE %s (
|
||||
id bigserial NOT NULL,
|
||||
passport varchar(45) NOT NULL,
|
||||
password varchar(32) NOT NULL,
|
||||
nickname varchar(45) NOT NULL,
|
||||
create_time timestamp NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
CONSTRAINT %s UNIQUE ("passport", "password")
|
||||
) ;`, table, uniqueName,
|
||||
)); err != nil {
|
||||
gtest.Fatal(err)
|
||||
}
|
||||
defer dropTable(table)
|
||||
|
||||
// string type 1.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("passport,password").Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).Where("id", 1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "n1")
|
||||
})
|
||||
|
||||
// string type 2.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("passport", "password").Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).Where("id", 1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "n1")
|
||||
})
|
||||
|
||||
// slice.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict(g.Slice{"passport", "password"}).Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).Where("id", 1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "n1")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Model_OnDuplicate(t *testing.T) {
|
||||
table := createInitTable()
|
||||
defer dropTable(table)
|
||||
|
||||
// string type 1.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("id").OnDuplicate("passport,password").Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// string type 2.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("id").OnDuplicate("passport", "password").Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// slice.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("id").OnDuplicate(g.Slice{"passport", "password"}).Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// map.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("id").OnDuplicate(g.Map{
|
||||
"passport": "nickname",
|
||||
"password": "nickname",
|
||||
}).Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["nickname"])
|
||||
t.Assert(one["password"], data["nickname"])
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// map+raw.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.MapStrStr{
|
||||
"id": "1",
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("id").OnDuplicate(g.Map{
|
||||
"passport": gdb.Raw("CONCAT(EXCLUDED.passport, '1')"),
|
||||
"password": gdb.Raw("CONCAT(EXCLUDED.password, '2')"),
|
||||
}).Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"]+"1")
|
||||
t.Assert(one["password"], data["password"]+"2")
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Model_OnDuplicateEx(t *testing.T) {
|
||||
table := createInitTable()
|
||||
defer dropTable(table)
|
||||
|
||||
// string type 1.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("id").OnDuplicateEx("nickname,create_time").Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// string type 2.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("id").OnDuplicateEx("nickname", "create_time").Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// slice.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("id").OnDuplicateEx(g.Slice{"nickname", "create_time"}).Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
|
||||
// map.
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
data := g.Map{
|
||||
"id": 1,
|
||||
"passport": "pp1",
|
||||
"password": "pw1",
|
||||
"nickname": "n1",
|
||||
"create_time": "2016-06-06",
|
||||
}
|
||||
_, err := db.Model(table).OnConflict("id").OnDuplicateEx(g.Map{
|
||||
"nickname": "nickname",
|
||||
"create_time": "nickname",
|
||||
}).Data(data).Save()
|
||||
t.AssertNil(err)
|
||||
one, err := db.Model(table).WherePri(1).One()
|
||||
t.AssertNil(err)
|
||||
t.Assert(one["passport"], data["passport"])
|
||||
t.Assert(one["password"], data["password"])
|
||||
t.Assert(one["nickname"], "name_1")
|
||||
})
|
||||
}
|
||||
|
||||
@ -37,12 +37,12 @@ func Test_LastInsertId(t *testing.T) {
|
||||
{"passport": "user2", "password": "pwd", "nickname": "nickname", "create_time": CreateTime},
|
||||
{"passport": "user3", "password": "pwd", "nickname": "nickname", "create_time": CreateTime},
|
||||
})
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
lastInsertId, err := res.LastInsertId()
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
t.Assert(lastInsertId, int64(3))
|
||||
rowsAffected, err := res.RowsAffected()
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
t.Assert(rowsAffected, int64(3))
|
||||
})
|
||||
}
|
||||
@ -58,29 +58,29 @@ func Test_TxLastInsertId(t *testing.T) {
|
||||
{"passport": "user2", "password": "pwd", "nickname": "nickname", "create_time": CreateTime},
|
||||
{"passport": "user3", "password": "pwd", "nickname": "nickname", "create_time": CreateTime},
|
||||
})
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
lastInsertId, err := res.LastInsertId()
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
t.AssertEQ(lastInsertId, int64(3))
|
||||
rowsAffected, err := res.RowsAffected()
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
t.AssertEQ(rowsAffected, int64(3))
|
||||
|
||||
res1, err := tx.Model(tableName).Insert(g.List{
|
||||
{"passport": "user4", "password": "pwd", "nickname": "nickname", "create_time": CreateTime},
|
||||
{"passport": "user5", "password": "pwd", "nickname": "nickname", "create_time": CreateTime},
|
||||
})
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
lastInsertId1, err := res1.LastInsertId()
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
t.AssertEQ(lastInsertId1, int64(5))
|
||||
rowsAffected1, err := res1.RowsAffected()
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
t.AssertEQ(rowsAffected1, int64(2))
|
||||
return nil
|
||||
|
||||
})
|
||||
t.Assert(err, nil)
|
||||
t.AssertNil(err)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ go 1.18
|
||||
|
||||
require (
|
||||
github.com/glebarez/go-sqlite v1.21.2
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
@ -5,9 +5,6 @@
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
// Package sqlite implements gdb.Driver, which supports operations for database SQLite.
|
||||
//
|
||||
// Note:
|
||||
// 1. It does not support Save features.
|
||||
package sqlite
|
||||
|
||||
import (
|
||||
|
||||
@ -10,8 +10,6 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
)
|
||||
|
||||
@ -24,14 +22,6 @@ func (d *Driver) DoFilter(ctx context.Context, link gdb.Link, sql string, args [
|
||||
|
||||
case gstr.HasPrefix(sql, gdb.InsertOperationReplace):
|
||||
sql = "INSERT OR REPLACE" + sql[len(gdb.InsertOperationReplace):]
|
||||
|
||||
default:
|
||||
if gstr.Contains(sql, gdb.InsertOnDuplicateKeyUpdate) {
|
||||
return sql, args, gerror.NewCode(
|
||||
gcode.CodeNotSupported,
|
||||
`Save operation is not supported by sqlite driver`,
|
||||
)
|
||||
}
|
||||
}
|
||||
return d.Core.DoFilter(ctx, link, sql, args)
|
||||
}
|
||||
|
||||
71
contrib/drivers/sqlite/sqlite_format_upsert.go
Normal file
71
contrib/drivers/sqlite/sqlite_format_upsert.go
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package sqlite
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
// FormatUpsert returns SQL clause of type upsert for SQLite.
|
||||
// For example: ON CONFLICT (id) DO UPDATE SET ...
|
||||
func (d *Driver) FormatUpsert(columns []string, list gdb.List, option gdb.DoInsertOption) (string, error) {
|
||||
if len(option.OnConflict) == 0 {
|
||||
return "", gerror.NewCode(
|
||||
gcode.CodeMissingParameter, `Please specify conflict columns`,
|
||||
)
|
||||
}
|
||||
|
||||
var onDuplicateStr string
|
||||
if option.OnDuplicateStr != "" {
|
||||
onDuplicateStr = option.OnDuplicateStr
|
||||
} else if len(option.OnDuplicateMap) > 0 {
|
||||
for k, v := range option.OnDuplicateMap {
|
||||
if len(onDuplicateStr) > 0 {
|
||||
onDuplicateStr += ","
|
||||
}
|
||||
switch v.(type) {
|
||||
case gdb.Raw, *gdb.Raw:
|
||||
onDuplicateStr += fmt.Sprintf(
|
||||
"%s=%s",
|
||||
d.Core.QuoteWord(k),
|
||||
v,
|
||||
)
|
||||
default:
|
||||
onDuplicateStr += fmt.Sprintf(
|
||||
"%s=EXCLUDED.%s",
|
||||
d.Core.QuoteWord(k),
|
||||
d.Core.QuoteWord(gconv.String(v)),
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, column := range columns {
|
||||
// If it's SAVE operation, do not automatically update the creating time.
|
||||
if d.Core.IsSoftCreatedFieldName(column) {
|
||||
continue
|
||||
}
|
||||
if len(onDuplicateStr) > 0 {
|
||||
onDuplicateStr += ","
|
||||
}
|
||||
onDuplicateStr += fmt.Sprintf(
|
||||
"%s=EXCLUDED.%s",
|
||||
d.Core.QuoteWord(column),
|
||||
d.Core.QuoteWord(column),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
conflictKeys := gstr.Join(option.OnConflict, ",")
|
||||
|
||||
return fmt.Sprintf("ON CONFLICT (%s) DO UPDATE SET ", conflictKeys) + onDuplicateStr, nil
|
||||
}
|
||||
@ -140,7 +140,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
Nickname string `gconv:"nickname"`
|
||||
CreateTime string `json:"create_time"`
|
||||
}
|
||||
timeStr := gtime.Now().String()
|
||||
timeStr := gtime.New("2024-10-01 12:01:01").String()
|
||||
result, err = db.Insert(ctx, table, User{
|
||||
Id: 3,
|
||||
Passport: "user_3",
|
||||
@ -162,7 +162,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
t.Assert(one["create_time"].GTime().String(), timeStr)
|
||||
|
||||
// *struct
|
||||
timeStr = gtime.Now().String()
|
||||
timeStr = gtime.New("2024-10-01 12:01:01").String()
|
||||
result, err = db.Insert(ctx, table, &User{
|
||||
Id: 4,
|
||||
Passport: "t4",
|
||||
@ -183,7 +183,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
t.Assert(one["create_time"].GTime().String(), timeStr)
|
||||
|
||||
// batch with Insert
|
||||
timeStr = gtime.Now().String()
|
||||
timeStr = gtime.New("2024-10-01 12:01:01").String()
|
||||
r, err := db.Insert(ctx, table, g.Slice{
|
||||
g.Map{
|
||||
"id": 200,
|
||||
@ -425,19 +425,22 @@ func Test_DB_BatchInsert_Struct(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_DB_Save(t *testing.T) {
|
||||
table := createInitTable()
|
||||
table := createTable()
|
||||
defer dropTable(table)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
timeStr := gtime.Now().String()
|
||||
_, err := db.Save(ctx, table, g.Map{
|
||||
"id": 1,
|
||||
"passport": "t1",
|
||||
"password": "25d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "T11",
|
||||
"create_time": timeStr,
|
||||
})
|
||||
t.Assert(err, ErrorSave)
|
||||
createTable("t_user")
|
||||
defer dropTable("t_user")
|
||||
|
||||
i := 10
|
||||
data := g.Map{
|
||||
"id": i,
|
||||
"passport": fmt.Sprintf(`t%d`, i),
|
||||
"password": fmt.Sprintf(`p%d`, i),
|
||||
"nickname": fmt.Sprintf(`T%d`, i),
|
||||
"create_time": gtime.Now().String(),
|
||||
}
|
||||
_, err := db.Save(ctx, "t_user", data, 10)
|
||||
gtest.AssertNE(err, nil)
|
||||
})
|
||||
}
|
||||
|
||||
@ -446,7 +449,7 @@ func Test_DB_Replace(t *testing.T) {
|
||||
defer dropTable(table)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
timeStr := gtime.Now().String()
|
||||
timeStr := gtime.New("2024-10-01 12:01:01").String()
|
||||
_, err := db.Replace(ctx, table, g.Map{
|
||||
"id": 1,
|
||||
"passport": "t1",
|
||||
|
||||
@ -11,8 +11,6 @@ import (
|
||||
|
||||
"github.com/gogf/gf/v2/container/garray"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/os/gfile"
|
||||
@ -27,9 +25,6 @@ var (
|
||||
configNode gdb.ConfigNode
|
||||
dbDir = gfile.Temp("sqlite")
|
||||
ctx = gctx.New()
|
||||
|
||||
// Error
|
||||
ErrorSave = gerror.NewCode(gcode.CodeNotSupported, `Save operation is not supported by sqlite driver`)
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@ -364,14 +364,58 @@ func Test_Model_Save(t *testing.T) {
|
||||
table := createTable()
|
||||
defer dropTable(table)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
_, err := db.Model(table).Data(g.Map{
|
||||
type User struct {
|
||||
Id int
|
||||
Passport string
|
||||
Password string
|
||||
NickName string
|
||||
CreateTime *gtime.Time
|
||||
}
|
||||
var (
|
||||
user User
|
||||
count int
|
||||
result sql.Result
|
||||
err error
|
||||
)
|
||||
|
||||
result, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "t111",
|
||||
"password": "25d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "T111",
|
||||
"passport": "CN",
|
||||
"password": "12345678",
|
||||
"nickname": "oldme",
|
||||
"create_time": CreateTime,
|
||||
}).Save()
|
||||
t.Assert(err, ErrorSave)
|
||||
}).OnConflict("id").Save()
|
||||
t.AssertNil(err)
|
||||
n, _ := result.RowsAffected()
|
||||
t.Assert(n, 1)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Id, 1)
|
||||
t.Assert(user.Passport, "CN")
|
||||
t.Assert(user.Password, "12345678")
|
||||
t.Assert(user.NickName, "oldme")
|
||||
t.Assert(user.CreateTime.String(), CreateTime)
|
||||
|
||||
_, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "CN",
|
||||
"password": "abc123456",
|
||||
"nickname": "to be not to be",
|
||||
"create_time": CreateTime,
|
||||
}).OnConflict("id").Save()
|
||||
t.AssertNil(err)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Passport, "CN")
|
||||
t.Assert(user.Password, "abc123456")
|
||||
t.Assert(user.NickName, "to be not to be")
|
||||
t.Assert(user.CreateTime.String(), CreateTime)
|
||||
|
||||
count, err = db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -3,8 +3,8 @@ module github.com/gogf/gf/contrib/drivers/sqlitecgo/v2
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.6.3
|
||||
github.com/gogf/gf/v2 v2.6.3
|
||||
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.7.0
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
github.com/mattn/go-sqlite3 v1.14.17
|
||||
)
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
Nickname string `gconv:"nickname"`
|
||||
CreateTime string `json:"create_time"`
|
||||
}
|
||||
timeStr := gtime.Now().String()
|
||||
timeStr := gtime.New("2024-10-01 12:01:01").String()
|
||||
result, err = db.Insert(ctx, table, User{
|
||||
Id: 3,
|
||||
Passport: "user_3",
|
||||
@ -162,7 +162,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
t.Assert(one["create_time"].GTime().String(), timeStr)
|
||||
|
||||
// *struct
|
||||
timeStr = gtime.Now().String()
|
||||
timeStr = gtime.New("2024-10-01 12:01:01").String()
|
||||
result, err = db.Insert(ctx, table, &User{
|
||||
Id: 4,
|
||||
Passport: "t4",
|
||||
@ -183,7 +183,7 @@ func Test_DB_Insert(t *testing.T) {
|
||||
t.Assert(one["create_time"].GTime().String(), timeStr)
|
||||
|
||||
// batch with Insert
|
||||
timeStr = gtime.Now().String()
|
||||
timeStr = gtime.New("2024-10-01 12:01:01").String()
|
||||
r, err := db.Insert(ctx, table, g.Slice{
|
||||
g.Map{
|
||||
"id": 200,
|
||||
@ -425,19 +425,22 @@ func Test_DB_BatchInsert_Struct(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_DB_Save(t *testing.T) {
|
||||
table := createInitTable()
|
||||
table := createTable()
|
||||
defer dropTable(table)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
timeStr := gtime.Now().String()
|
||||
_, err := db.Save(ctx, table, g.Map{
|
||||
"id": 1,
|
||||
"passport": "t1",
|
||||
"password": "25d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "T11",
|
||||
"create_time": timeStr,
|
||||
})
|
||||
t.Assert(err, ErrorSave)
|
||||
createTable("t_user")
|
||||
defer dropTable("t_user")
|
||||
|
||||
i := 10
|
||||
data := g.Map{
|
||||
"id": i,
|
||||
"passport": fmt.Sprintf(`t%d`, i),
|
||||
"password": fmt.Sprintf(`p%d`, i),
|
||||
"nickname": fmt.Sprintf(`T%d`, i),
|
||||
"create_time": gtime.Now().String(),
|
||||
}
|
||||
_, err := db.Save(ctx, "t_user", data, 10)
|
||||
gtest.AssertNE(err, nil)
|
||||
})
|
||||
}
|
||||
|
||||
@ -446,7 +449,7 @@ func Test_DB_Replace(t *testing.T) {
|
||||
defer dropTable(table)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
timeStr := gtime.Now().String()
|
||||
timeStr := gtime.New("2024-10-01 12:01:01").String()
|
||||
_, err := db.Replace(ctx, table, g.Map{
|
||||
"id": 1,
|
||||
"passport": "t1",
|
||||
|
||||
@ -364,14 +364,58 @@ func Test_Model_Save(t *testing.T) {
|
||||
table := createTable()
|
||||
defer dropTable(table)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
_, err := db.Model(table).Data(g.Map{
|
||||
type User struct {
|
||||
Id int
|
||||
Passport string
|
||||
Password string
|
||||
NickName string
|
||||
CreateTime *gtime.Time
|
||||
}
|
||||
var (
|
||||
user User
|
||||
count int
|
||||
result sql.Result
|
||||
err error
|
||||
)
|
||||
|
||||
result, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "t111",
|
||||
"password": "25d55ad283aa400af464c76d713c07ad",
|
||||
"nickname": "T111",
|
||||
"passport": "CN",
|
||||
"password": "12345678",
|
||||
"nickname": "oldme",
|
||||
"create_time": CreateTime,
|
||||
}).Save()
|
||||
t.Assert(err, ErrorSave)
|
||||
}).OnConflict("id").Save()
|
||||
t.AssertNil(err)
|
||||
n, _ := result.RowsAffected()
|
||||
t.Assert(n, 1)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Id, 1)
|
||||
t.Assert(user.Passport, "CN")
|
||||
t.Assert(user.Password, "12345678")
|
||||
t.Assert(user.NickName, "oldme")
|
||||
t.Assert(user.CreateTime.String(), CreateTime)
|
||||
|
||||
_, err = db.Model(table).Data(g.Map{
|
||||
"id": 1,
|
||||
"passport": "CN",
|
||||
"password": "abc123456",
|
||||
"nickname": "to be not to be",
|
||||
"create_time": CreateTime,
|
||||
}).OnConflict("id").Save()
|
||||
t.AssertNil(err)
|
||||
|
||||
err = db.Model(table).Scan(&user)
|
||||
t.AssertNil(err)
|
||||
t.Assert(user.Passport, "CN")
|
||||
t.Assert(user.Password, "abc123456")
|
||||
t.Assert(user.NickName, "to be not to be")
|
||||
t.Assert(user.CreateTime.String(), CreateTime)
|
||||
|
||||
count, err = db.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
t.Assert(count, 1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
160
contrib/metric/otelmetric/README.MD
Normal file
160
contrib/metric/otelmetric/README.MD
Normal file
@ -0,0 +1,160 @@
|
||||
# GoFrame Metric In OpenTelemetry
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
go get -u -v github.com/gogf/gf/contrib/metric/otelmetric/v2
|
||||
```
|
||||
|
||||
suggested using `go.mod`:
|
||||
|
||||
```
|
||||
require github.com/gogf/gf/contrib/metric/otelmetric/v2 latest
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
### [basic](../../../example/metric/basic/main.go)
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"go.opentelemetry.io/otel/exporters/prometheus"
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
|
||||
"github.com/gogf/gf/contrib/metric/otelmetric/v2"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
var (
|
||||
meter = gmetric.GetGlobalProvider().Meter(gmetric.MeterOption{
|
||||
Instrument: "github.com/gogf/gf/example/metric/basic",
|
||||
InstrumentVersion: "v1.0",
|
||||
})
|
||||
counter = meter.MustCounter(
|
||||
"goframe.metric.demo.counter",
|
||||
gmetric.MetricOption{
|
||||
Help: "This is a simple demo for Counter usage",
|
||||
Unit: "bytes",
|
||||
Attributes: gmetric.Attributes{
|
||||
gmetric.NewAttribute("const_label_1", 1),
|
||||
},
|
||||
},
|
||||
)
|
||||
upDownCounter = meter.MustUpDownCounter(
|
||||
"goframe.metric.demo.updown_counter",
|
||||
gmetric.MetricOption{
|
||||
Help: "This is a simple demo for UpDownCounter usage",
|
||||
Unit: "%",
|
||||
Attributes: gmetric.Attributes{
|
||||
gmetric.NewAttribute("const_label_2", 2),
|
||||
},
|
||||
},
|
||||
)
|
||||
histogram = meter.MustHistogram(
|
||||
"goframe.metric.demo.histogram",
|
||||
gmetric.MetricOption{
|
||||
Help: "This is a simple demo for histogram usage",
|
||||
Unit: "ms",
|
||||
Attributes: gmetric.Attributes{
|
||||
gmetric.NewAttribute("const_label_3", 3),
|
||||
},
|
||||
Buckets: []float64{0, 10, 20, 50, 100, 500, 1000, 2000, 5000, 10000},
|
||||
},
|
||||
)
|
||||
observableCounter = meter.MustObservableCounter(
|
||||
"goframe.metric.demo.observable_counter",
|
||||
gmetric.MetricOption{
|
||||
Help: "This is a simple demo for ObservableCounter usage",
|
||||
Unit: "%",
|
||||
Attributes: gmetric.Attributes{
|
||||
gmetric.NewAttribute("const_label_4", 4),
|
||||
},
|
||||
},
|
||||
)
|
||||
observableUpDownCounter = meter.MustObservableUpDownCounter(
|
||||
"goframe.metric.demo.observable_updown_counter",
|
||||
gmetric.MetricOption{
|
||||
Help: "This is a simple demo for ObservableUpDownCounter usage",
|
||||
Unit: "%",
|
||||
Attributes: gmetric.Attributes{
|
||||
gmetric.NewAttribute("const_label_5", 5),
|
||||
},
|
||||
},
|
||||
)
|
||||
observableGauge = meter.MustObservableGauge(
|
||||
"goframe.metric.demo.observable_gauge",
|
||||
gmetric.MetricOption{
|
||||
Help: "This is a simple demo for ObservableGauge usage",
|
||||
Unit: "%",
|
||||
Attributes: gmetric.Attributes{
|
||||
gmetric.NewAttribute("const_label_6", 6),
|
||||
},
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
func main() {
|
||||
var ctx = gctx.New()
|
||||
|
||||
// Callback for observable metrics.
|
||||
meter.MustRegisterCallback(func(ctx context.Context, obs gmetric.Observer) error {
|
||||
obs.Observe(observableCounter, 10)
|
||||
obs.Observe(observableUpDownCounter, 20)
|
||||
obs.Observe(observableGauge, 30)
|
||||
return nil
|
||||
}, observableCounter, observableUpDownCounter, observableGauge)
|
||||
|
||||
// Prometheus exporter to export metrics as Prometheus format.
|
||||
exporter, err := prometheus.New(
|
||||
prometheus.WithoutCounterSuffixes(),
|
||||
prometheus.WithoutUnits(),
|
||||
)
|
||||
if err != nil {
|
||||
g.Log().Fatal(ctx, err)
|
||||
}
|
||||
|
||||
// OpenTelemetry provider.
|
||||
provider := otelmetric.MustProvider(metric.WithReader(exporter))
|
||||
provider.SetAsGlobal()
|
||||
defer provider.Shutdown(ctx)
|
||||
|
||||
// Counter.
|
||||
counter.Inc(ctx)
|
||||
counter.Add(ctx, 10)
|
||||
|
||||
// UpDownCounter.
|
||||
upDownCounter.Inc(ctx)
|
||||
upDownCounter.Add(ctx, 10)
|
||||
upDownCounter.Dec(ctx)
|
||||
|
||||
// Record values for histogram.
|
||||
histogram.Record(1)
|
||||
histogram.Record(20)
|
||||
histogram.Record(30)
|
||||
histogram.Record(101)
|
||||
histogram.Record(2000)
|
||||
histogram.Record(9000)
|
||||
histogram.Record(20000)
|
||||
|
||||
// HTTP Server for metrics exporting.
|
||||
s := g.Server()
|
||||
s.BindHandler("/metrics", ghttp.WrapH(promhttp.Handler()))
|
||||
s.SetPort(8000)
|
||||
s.Run()
|
||||
}
|
||||
```
|
||||
|
||||
### [more examples](../../../example/metric/)
|
||||
|
||||
## License
|
||||
|
||||
`GoFrame Polaris` is licensed under the [MIT License](../../../LICENSE), 100% free and open-source, forever.
|
||||
|
||||
44
contrib/metric/otelmetric/go.mod
Normal file
44
contrib/metric/otelmetric/go.mod
Normal file
@ -0,0 +1,44 @@
|
||||
module github.com/gogf/gf/contrib/metric/otelmetric/v2
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
github.com/prometheus/client_golang v1.19.0
|
||||
go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0
|
||||
go.opentelemetry.io/otel v1.24.0
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.46.0
|
||||
go.opentelemetry.io/otel/metric v1.24.0
|
||||
go.opentelemetry.io/otel/sdk v1.24.0
|
||||
go.opentelemetry.io/otel/sdk/metric v1.24.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/go-logr/logr v1.4.1 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/grokify/html-strip-tags-go v0.0.1 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/prometheus/client_model v0.6.0 // indirect
|
||||
github.com/prometheus/common v0.48.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/protobuf v1.32.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
replace github.com/gogf/gf/v2 => ../../../
|
||||
75
contrib/metric/otelmetric/go.sum
Normal file
75
contrib/metric/otelmetric/go.sum
Normal file
@ -0,0 +1,75 @@
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
|
||||
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
|
||||
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=
|
||||
github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
|
||||
github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k=
|
||||
github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos=
|
||||
github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8=
|
||||
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
|
||||
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
|
||||
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
|
||||
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
|
||||
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
||||
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 h1:dg9y+7ArpumB6zwImJv47RHfdgOGQ1EMkzP5vLkEnTU=
|
||||
go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0/go.mod h1:Ul4MtXqu/hJBM+v7a6dCF0nHwckPMLpIpLeCi4+zfdw=
|
||||
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
||||
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.46.0 h1:I8WIFXR351FoLJYuloU4EgXbtNX2URfU/85pUPheIEQ=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.46.0/go.mod h1:ztwVUHe5DTR/1v7PeuGRnU5Bbd4QKYwApWmuutKsJSs=
|
||||
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
|
||||
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
|
||||
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
|
||||
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.24.0 h1:yyMQrPzF+k88/DbH7o4FMAs80puqd+9osbiBrJrz/w8=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.24.0/go.mod h1:I6Y5FjH6rvEnTTAYQz3Mmv2kl6Ek5IIrmwTLqMrrOE0=
|
||||
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
|
||||
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
||||
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
31
contrib/metric/otelmetric/otelmetric.go
Normal file
31
contrib/metric/otelmetric/otelmetric.go
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
// Package otelmetric provides metric functionalities using OpenTelemetry metric.
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// NewProvider creates and returns a metrics provider.
|
||||
func NewProvider(option ...Option) (gmetric.Provider, error) {
|
||||
provider, err := newProvider(option...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return provider, nil
|
||||
}
|
||||
|
||||
// MustProvider creates and returns a metrics provider.
|
||||
// It panics if any error occurs.
|
||||
func MustProvider(option ...Option) gmetric.Provider {
|
||||
provider, err := NewProvider(option...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return provider
|
||||
}
|
||||
53
contrib/metric/otelmetric/otelmetric_callback.go
Normal file
53
contrib/metric/otelmetric/otelmetric_callback.go
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// localObserver implements interface gmetric.Observer.
|
||||
type localObserver struct {
|
||||
metric.Observer
|
||||
gmetric.MeterOption
|
||||
}
|
||||
|
||||
// newObserver creates and returns gmetric.Observer.
|
||||
func newObserver(observer metric.Observer, meterOption gmetric.MeterOption) gmetric.Observer {
|
||||
return &localObserver{
|
||||
Observer: observer,
|
||||
MeterOption: meterOption,
|
||||
}
|
||||
}
|
||||
|
||||
// Observe observes the value for certain initialized Metric.
|
||||
// It adds the value to total result if the observed Metrics is type of Counter.
|
||||
// It sets the value as the result if the observed Metrics is type of Gauge.
|
||||
func (l *localObserver) Observe(om gmetric.ObservableMetric, value float64, option ...gmetric.Option) {
|
||||
var (
|
||||
m = om.(gmetric.Metric)
|
||||
constOption = getConstOptionByMetric(l.MeterOption, m)
|
||||
dynamicOption = getDynamicOptionByMetricOption(option...)
|
||||
globalAttributesOption = getGlobalAttributesOption(gmetric.GetGlobalAttributesOption{
|
||||
Instrument: m.Info().Instrument().Name(),
|
||||
InstrumentVersion: m.Info().Instrument().Version(),
|
||||
})
|
||||
observeOptions = make([]metric.ObserveOption, 0)
|
||||
)
|
||||
if globalAttributesOption != nil {
|
||||
observeOptions = append(observeOptions, globalAttributesOption)
|
||||
}
|
||||
if constOption != nil {
|
||||
observeOptions = append(observeOptions, constOption)
|
||||
}
|
||||
if dynamicOption != nil {
|
||||
observeOptions = append(observeOptions, dynamicOption)
|
||||
}
|
||||
l.Observer.ObserveFloat64(metricToFloat64Observable(m), value, observeOptions...)
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// localCounterPerformer is an implementer for interface gmetric.CounterPerformer.
|
||||
type localCounterPerformer struct {
|
||||
gmetric.MeterOption
|
||||
gmetric.MetricOption
|
||||
metric.Float64Counter
|
||||
constOption metric.MeasurementOption
|
||||
}
|
||||
|
||||
// newCounterPerformer creates and returns a CounterPerformer that truly takes action to implement Counter.
|
||||
func (l *localMeterPerformer) newCounterPerformer(
|
||||
meter metric.Meter,
|
||||
metricName string,
|
||||
metricOption gmetric.MetricOption,
|
||||
) (gmetric.CounterPerformer, error) {
|
||||
var (
|
||||
options = []metric.Float64CounterOption{
|
||||
metric.WithDescription(metricOption.Help),
|
||||
metric.WithUnit(metricOption.Unit),
|
||||
}
|
||||
)
|
||||
counter, err := meter.Float64Counter(metricName, options...)
|
||||
if err != nil {
|
||||
return nil, gerror.WrapCodef(
|
||||
gcode.CodeInternalError,
|
||||
err,
|
||||
`create Float64Counter "%s" failed with option: %s`,
|
||||
metricName, gjson.MustEncodeString(metricOption),
|
||||
)
|
||||
}
|
||||
return &localCounterPerformer{
|
||||
MetricOption: metricOption,
|
||||
MeterOption: l.MeterOption,
|
||||
Float64Counter: counter,
|
||||
constOption: genConstOptionForMetric(l.MeterOption, metricOption),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Inc increments the counter by 1.
|
||||
func (l *localCounterPerformer) Inc(ctx context.Context, option ...gmetric.Option) {
|
||||
l.Add(ctx, 1, option...)
|
||||
}
|
||||
|
||||
// Add adds the given value to the counter. It panics if the value is < 0.
|
||||
func (l *localCounterPerformer) Add(ctx context.Context, increment float64, option ...gmetric.Option) {
|
||||
l.Float64Counter.Add(ctx, increment, generateAddOptions(l.MeterOption, l.constOption, option...)...)
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// localHistogramPerformer is an implementer for interface HistogramPerformer.
|
||||
type localHistogramPerformer struct {
|
||||
gmetric.MeterOption
|
||||
gmetric.MetricOption
|
||||
metric.Float64Histogram
|
||||
constOption metric.MeasurementOption
|
||||
}
|
||||
|
||||
// newHistogramPerformer creates and returns a HistogramPerformer that truly takes action to implement Histogram.
|
||||
func (l *localMeterPerformer) newHistogramPerformer(
|
||||
meter metric.Meter,
|
||||
metricName string,
|
||||
metricOption gmetric.MetricOption,
|
||||
) (gmetric.HistogramPerformer, error) {
|
||||
histogram, err := meter.Float64Histogram(
|
||||
metricName,
|
||||
metric.WithDescription(metricOption.Help),
|
||||
metric.WithUnit(metricOption.Unit),
|
||||
metric.WithExplicitBucketBoundaries(metricOption.Buckets...),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, gerror.WrapCodef(
|
||||
gcode.CodeInternalError,
|
||||
err,
|
||||
`create Float64Histogram "%s" failed with option: %s`,
|
||||
metricName, gjson.MustEncodeString(metricOption),
|
||||
)
|
||||
}
|
||||
return &localHistogramPerformer{
|
||||
MeterOption: l.MeterOption,
|
||||
MetricOption: metricOption,
|
||||
Float64Histogram: histogram,
|
||||
constOption: genConstOptionForMetric(l.MeterOption, metricOption),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Record adds a single value to the histogram. The value is usually positive or zero.
|
||||
func (l *localHistogramPerformer) Record(increment float64, option ...gmetric.Option) {
|
||||
l.Float64Histogram.Record(
|
||||
context.Background(),
|
||||
increment,
|
||||
l.generateRecordOptions(option...)...,
|
||||
)
|
||||
}
|
||||
|
||||
func (l *localHistogramPerformer) generateRecordOptions(option ...gmetric.Option) []metric.RecordOption {
|
||||
var (
|
||||
dynamicOption = getDynamicOptionByMetricOption(option...)
|
||||
recordOptions = make([]metric.RecordOption, 0)
|
||||
globalAttributesOption = getGlobalAttributesOption(gmetric.GetGlobalAttributesOption{
|
||||
Instrument: l.MeterOption.Instrument,
|
||||
InstrumentVersion: l.MeterOption.InstrumentVersion,
|
||||
})
|
||||
)
|
||||
if globalAttributesOption != nil {
|
||||
recordOptions = append(recordOptions, globalAttributesOption)
|
||||
}
|
||||
if l.constOption != nil {
|
||||
recordOptions = append(recordOptions, l.constOption)
|
||||
}
|
||||
if dynamicOption != nil {
|
||||
recordOptions = append(recordOptions, dynamicOption)
|
||||
}
|
||||
return recordOptions
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// localCounterPerformer is an implementer for interface CounterPerformer.
|
||||
type localObservableCounterPerformer struct {
|
||||
gmetric.ObservableMetric
|
||||
metric.Float64ObservableCounter
|
||||
}
|
||||
|
||||
// newCounterPerformer creates and returns a CounterPerformer that truly takes action to implement Counter.
|
||||
func (l *localMeterPerformer) newObservableCounterPerformer(
|
||||
meter metric.Meter,
|
||||
metricName string,
|
||||
metricOption gmetric.MetricOption,
|
||||
) (gmetric.ObservableCounterPerformer, error) {
|
||||
var (
|
||||
options = []metric.Float64ObservableCounterOption{
|
||||
metric.WithDescription(metricOption.Help),
|
||||
metric.WithUnit(metricOption.Unit),
|
||||
}
|
||||
)
|
||||
if metricOption.Callback != nil {
|
||||
callback := metric.WithFloat64Callback(func(ctx context.Context, observer metric.Float64Observer) error {
|
||||
return metricOption.Callback(ctx, l.newMetricObserver(metricOption, observer))
|
||||
})
|
||||
options = append(options, callback)
|
||||
}
|
||||
counter, err := meter.Float64ObservableCounter(metricName, options...)
|
||||
if err != nil {
|
||||
return nil, gerror.WrapCodef(
|
||||
gcode.CodeInternalError,
|
||||
err,
|
||||
`create Float64ObservableCounter "%s" failed with option: %s`,
|
||||
metricName, gjson.MustEncodeString(metricOption),
|
||||
)
|
||||
}
|
||||
return &localObservableCounterPerformer{
|
||||
Float64ObservableCounter: counter,
|
||||
}, nil
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// localGaugePerformer is an implementer for interface GaugePerformer.
|
||||
type localObservableGaugePerformer struct {
|
||||
gmetric.ObservableMetric
|
||||
metric.Float64ObservableGauge
|
||||
}
|
||||
|
||||
// newGaugePerformer creates and returns a GaugePerformer that truly takes action to implement Gauge.
|
||||
func (l *localMeterPerformer) newObservableGaugePerformer(
|
||||
meter metric.Meter,
|
||||
metricName string,
|
||||
metricOption gmetric.MetricOption,
|
||||
) (gmetric.ObservableGaugePerformer, error) {
|
||||
var (
|
||||
options = []metric.Float64ObservableGaugeOption{
|
||||
metric.WithDescription(metricOption.Help),
|
||||
metric.WithUnit(metricOption.Unit),
|
||||
}
|
||||
)
|
||||
if metricOption.Callback != nil {
|
||||
callback := metric.WithFloat64Callback(func(ctx context.Context, observer metric.Float64Observer) error {
|
||||
return metricOption.Callback(ctx, l.newMetricObserver(metricOption, observer))
|
||||
})
|
||||
options = append(options, callback)
|
||||
}
|
||||
gauge, err := meter.Float64ObservableGauge(metricName, options...)
|
||||
if err != nil {
|
||||
return nil, gerror.WrapCodef(
|
||||
gcode.CodeInternalError,
|
||||
err,
|
||||
`create Float64ObservableGauge "%s" failed with option: %s`,
|
||||
metricName, gjson.MustEncodeString(metricOption),
|
||||
)
|
||||
}
|
||||
return &localObservableGaugePerformer{
|
||||
Float64ObservableGauge: gauge,
|
||||
}, nil
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// localObservableUpDownCounterPerformer is an implementer for interface CounterPerformer.
|
||||
type localObservableUpDownCounterPerformer struct {
|
||||
gmetric.ObservableMetric
|
||||
metric.Float64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// newObservableUpDownCounterPerformer creates and returns a UpDownCounterPerformer that truly takes action to
|
||||
// implement ObservableUpDownCounter.
|
||||
func (l *localMeterPerformer) newObservableUpDownCounterPerformer(
|
||||
meter metric.Meter,
|
||||
metricName string,
|
||||
metricOption gmetric.MetricOption,
|
||||
) (gmetric.ObservableUpDownCounterPerformer, error) {
|
||||
var (
|
||||
options = []metric.Float64ObservableUpDownCounterOption{
|
||||
metric.WithDescription(metricOption.Help),
|
||||
metric.WithUnit(metricOption.Unit),
|
||||
}
|
||||
)
|
||||
if metricOption.Callback != nil {
|
||||
callback := metric.WithFloat64Callback(func(ctx context.Context, observer metric.Float64Observer) error {
|
||||
return metricOption.Callback(ctx, l.newMetricObserver(metricOption, observer))
|
||||
})
|
||||
options = append(options, callback)
|
||||
}
|
||||
counter, err := meter.Float64ObservableUpDownCounter(metricName, options...)
|
||||
if err != nil {
|
||||
return nil, gerror.WrapCodef(
|
||||
gcode.CodeInternalError,
|
||||
err,
|
||||
`create Float64ObservableUpDownCounter "%s" failed with option: %s`,
|
||||
metricName, gjson.MustEncodeString(metricOption),
|
||||
)
|
||||
}
|
||||
return &localObservableUpDownCounterPerformer{
|
||||
Float64ObservableUpDownCounter: counter,
|
||||
}, nil
|
||||
}
|
||||
143
contrib/metric/otelmetric/otelmetric_meter_performer.go
Normal file
143
contrib/metric/otelmetric/otelmetric_meter_performer.go
Normal file
@ -0,0 +1,143 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
otelmetric "go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
|
||||
"github.com/gogf/gf/v2/container/gset"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// localMeterPerformer implements interface gmetric.Performer.
|
||||
type localMeterPerformer struct {
|
||||
gmetric.MeterOption
|
||||
*metric.MeterProvider
|
||||
}
|
||||
|
||||
// newPerformer creates and returns gmetric.Meter.
|
||||
func newMeterPerformer(provider *metric.MeterProvider, option gmetric.MeterOption) gmetric.MeterPerformer {
|
||||
meterPerformer := &localMeterPerformer{
|
||||
MeterOption: option,
|
||||
MeterProvider: provider,
|
||||
}
|
||||
return meterPerformer
|
||||
}
|
||||
|
||||
// CounterPerformer creates and returns a CounterPerformer that performs
|
||||
// the operations for Counter metric.
|
||||
func (l *localMeterPerformer) CounterPerformer(name string, option gmetric.MetricOption) (gmetric.CounterPerformer, error) {
|
||||
return l.newCounterPerformer(l.createMeter(), name, option)
|
||||
}
|
||||
|
||||
// UpDownCounterPerformer creates and returns a UpDownCounterPerformer that performs
|
||||
// the operations for UpDownCounter metric.
|
||||
func (l *localMeterPerformer) UpDownCounterPerformer(name string, option gmetric.MetricOption) (gmetric.UpDownCounterPerformer, error) {
|
||||
return l.newUpDownCounterPerformer(l.createMeter(), name, option)
|
||||
}
|
||||
|
||||
// HistogramPerformer creates and returns a HistogramPerformer that performs
|
||||
// the operations for Histogram metric.
|
||||
func (l *localMeterPerformer) HistogramPerformer(name string, option gmetric.MetricOption) (gmetric.HistogramPerformer, error) {
|
||||
return l.newHistogramPerformer(l.createMeter(), name, option)
|
||||
}
|
||||
|
||||
// ObservableCounterPerformer creates and returns an ObservableMetric that performs
|
||||
// the operations for ObservableCounter metric.
|
||||
func (l *localMeterPerformer) ObservableCounterPerformer(name string, option gmetric.MetricOption) (gmetric.ObservableMetric, error) {
|
||||
return l.newObservableCounterPerformer(l.createMeter(), name, option)
|
||||
}
|
||||
|
||||
// ObservableUpDownCounterPerformer creates and returns an ObservableMetric that performs
|
||||
// the operations for ObservableUpDownCounter metric.
|
||||
func (l *localMeterPerformer) ObservableUpDownCounterPerformer(name string, option gmetric.MetricOption) (gmetric.ObservableMetric, error) {
|
||||
return l.newObservableUpDownCounterPerformer(l.createMeter(), name, option)
|
||||
}
|
||||
|
||||
// ObservableGaugePerformer creates and returns an ObservableMetric that performs
|
||||
// the operations for ObservableGauge metric.
|
||||
func (l *localMeterPerformer) ObservableGaugePerformer(name string, option gmetric.MetricOption) (gmetric.ObservableMetric, error) {
|
||||
return l.newObservableGaugePerformer(l.createMeter(), name, option)
|
||||
}
|
||||
|
||||
// RegisterCallback registers callback on certain metrics.
|
||||
// A callback is bound to certain component and version, it is called when the associated metrics are read.
|
||||
// Multiple callbacks on the same component and version will be called by their registered sequence.
|
||||
func (l *localMeterPerformer) RegisterCallback(
|
||||
callback gmetric.Callback, observableMetrics ...gmetric.ObservableMetric,
|
||||
) error {
|
||||
var metrics = make([]gmetric.Metric, 0)
|
||||
for _, v := range observableMetrics {
|
||||
m, ok := v.(gmetric.Metric)
|
||||
if !ok {
|
||||
return gerror.NewCodef(
|
||||
gcode.CodeInvalidParameter,
|
||||
`invalid metric parameter "%s" for RegisterCallback, which does not implement interface Metric`,
|
||||
reflect.TypeOf(v).String(),
|
||||
)
|
||||
}
|
||||
metrics = append(metrics, m)
|
||||
}
|
||||
// group the metric by instrument and instrument version.
|
||||
var (
|
||||
instrumentSet = gset.NewStrSet()
|
||||
underlyingMeterMap = map[otelmetric.Meter][]otelmetric.Observable{}
|
||||
)
|
||||
for _, m := range metrics {
|
||||
var meter = l.Meter(
|
||||
m.Info().Instrument().Name(),
|
||||
otelmetric.WithInstrumentationVersion(m.Info().Instrument().Version()),
|
||||
)
|
||||
instrumentSet.Add(fmt.Sprintf(
|
||||
`%s@%s`,
|
||||
m.Info().Instrument().Name(),
|
||||
m.Info().Instrument().Version(),
|
||||
))
|
||||
if _, ok := underlyingMeterMap[meter]; !ok {
|
||||
underlyingMeterMap[meter] = make([]otelmetric.Observable, 0)
|
||||
}
|
||||
underlyingMeterMap[meter] = append(underlyingMeterMap[meter], metricToFloat64Observable(m))
|
||||
}
|
||||
if len(underlyingMeterMap) > 1 {
|
||||
return gerror.NewCodef(
|
||||
gcode.CodeInvalidParameter,
|
||||
`multiple instrument or instrument version metrics used in the same callback: %s`,
|
||||
instrumentSet.Join(","),
|
||||
)
|
||||
}
|
||||
// do callback registering.
|
||||
for meter, observables := range underlyingMeterMap {
|
||||
_, err := meter.RegisterCallback(
|
||||
func(ctx context.Context, observer otelmetric.Observer) error {
|
||||
return callback(ctx, newObserver(observer, l.MeterOption))
|
||||
},
|
||||
observables...,
|
||||
)
|
||||
if err != nil {
|
||||
return gerror.WrapCode(
|
||||
gcode.CodeInternalError, err,
|
||||
`RegisterCallback failed`,
|
||||
)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// createMeter creates and returns an OpenTelemetry Meter.
|
||||
func (l *localMeterPerformer) createMeter() otelmetric.Meter {
|
||||
return l.Meter(
|
||||
l.Instrument,
|
||||
otelmetric.WithInstrumentationVersion(l.InstrumentVersion),
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// localUpDownCounterPerformer is an implementer for interface gmetric.UpDownCounterPerformer.
|
||||
type localUpDownCounterPerformer struct {
|
||||
gmetric.MeterOption
|
||||
gmetric.MetricOption
|
||||
metric.Float64UpDownCounter
|
||||
constOption metric.MeasurementOption
|
||||
}
|
||||
|
||||
// newUpDownCounterPerformer creates and returns a CounterPerformer that truly takes action to implement Counter.
|
||||
func (l *localMeterPerformer) newUpDownCounterPerformer(
|
||||
meter metric.Meter,
|
||||
metricName string,
|
||||
metricOption gmetric.MetricOption,
|
||||
) (gmetric.UpDownCounterPerformer, error) {
|
||||
var (
|
||||
options = []metric.Float64UpDownCounterOption{
|
||||
metric.WithDescription(metricOption.Help),
|
||||
metric.WithUnit(metricOption.Unit),
|
||||
}
|
||||
)
|
||||
counter, err := meter.Float64UpDownCounter(metricName, options...)
|
||||
if err != nil {
|
||||
return nil, gerror.WrapCodef(
|
||||
gcode.CodeInternalError,
|
||||
err,
|
||||
`create Float64Counter "%s" failed with config: %s`,
|
||||
metricName, gjson.MustEncodeString(metricOption),
|
||||
)
|
||||
}
|
||||
return &localUpDownCounterPerformer{
|
||||
MeterOption: l.MeterOption,
|
||||
MetricOption: metricOption,
|
||||
Float64UpDownCounter: counter,
|
||||
constOption: genConstOptionForMetric(l.MeterOption, metricOption),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Inc increments the counter by 1.
|
||||
func (l *localUpDownCounterPerformer) Inc(ctx context.Context, option ...gmetric.Option) {
|
||||
l.Add(ctx, 1, option...)
|
||||
}
|
||||
|
||||
// Dec decrements the counter by 1.
|
||||
func (l *localUpDownCounterPerformer) Dec(ctx context.Context, option ...gmetric.Option) {
|
||||
l.Add(ctx, -1, option...)
|
||||
}
|
||||
|
||||
// Add adds the given value to the counter.
|
||||
func (l *localUpDownCounterPerformer) Add(ctx context.Context, increment float64, option ...gmetric.Option) {
|
||||
l.Float64UpDownCounter.Add(ctx, increment, generateAddOptions(l.MeterOption, l.constOption, option...)...)
|
||||
}
|
||||
56
contrib/metric/otelmetric/otelmetric_metric_callback.go
Normal file
56
contrib/metric/otelmetric/otelmetric_metric_callback.go
Normal file
@ -0,0 +1,56 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// localMetricObserver implements interface gmetric.CallbackObserver.
|
||||
type localMetricObserver struct {
|
||||
gmetric.MeterOption
|
||||
gmetric.MetricOption
|
||||
metric.Float64Observer
|
||||
}
|
||||
|
||||
func (l *localMeterPerformer) newMetricObserver(
|
||||
metricOption gmetric.MetricOption,
|
||||
float64Observer metric.Float64Observer,
|
||||
) gmetric.MetricObserver {
|
||||
return &localMetricObserver{
|
||||
MeterOption: l.MeterOption,
|
||||
MetricOption: metricOption,
|
||||
Float64Observer: float64Observer,
|
||||
}
|
||||
}
|
||||
|
||||
// Observe observes the value for certain initialized Metric.
|
||||
// It adds the value to total result if the observed Metrics is type of Counter.
|
||||
// It sets the value as the result if the observed Metrics is type of Gauge.
|
||||
func (l *localMetricObserver) Observe(value float64, option ...gmetric.Option) {
|
||||
var (
|
||||
constOption = genConstOptionForMetric(l.MeterOption, l.MetricOption)
|
||||
dynamicOption = getDynamicOptionByMetricOption(option...)
|
||||
globalAttributesOption = getGlobalAttributesOption(gmetric.GetGlobalAttributesOption{
|
||||
Instrument: l.Instrument,
|
||||
InstrumentVersion: l.InstrumentVersion,
|
||||
})
|
||||
observeOptions = make([]metric.ObserveOption, 0)
|
||||
)
|
||||
if globalAttributesOption != nil {
|
||||
observeOptions = append(observeOptions, globalAttributesOption)
|
||||
}
|
||||
if constOption != nil {
|
||||
observeOptions = append(observeOptions, constOption)
|
||||
}
|
||||
if dynamicOption != nil {
|
||||
observeOptions = append(observeOptions, dynamicOption)
|
||||
}
|
||||
l.Float64Observer.Observe(value, observeOptions...)
|
||||
}
|
||||
108
contrib/metric/otelmetric/otelmetric_option.go
Normal file
108
contrib/metric/otelmetric/otelmetric_option.go
Normal file
@ -0,0 +1,108 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
)
|
||||
|
||||
// newProviderConfigByOptions returns a config configured with options.
|
||||
func newProviderConfigByOptions(options []Option) providerConfig {
|
||||
conf := providerConfig{}
|
||||
for _, o := range options {
|
||||
conf = o.apply(conf)
|
||||
}
|
||||
return conf
|
||||
}
|
||||
|
||||
// Option applies a configuration option value to a MeterProvider.
|
||||
type Option interface {
|
||||
apply(providerConfig) providerConfig
|
||||
}
|
||||
|
||||
// optionFunc applies a set of options to a config.
|
||||
type optionFunc func(providerConfig) providerConfig
|
||||
|
||||
// apply returns a config with option(s) applied.
|
||||
func (o optionFunc) apply(conf providerConfig) providerConfig {
|
||||
return o(conf)
|
||||
}
|
||||
|
||||
// providerConfig is the configuration for Provider.
|
||||
type providerConfig struct {
|
||||
viewOption metric.Option
|
||||
readerOption metric.Option
|
||||
resourceOption metric.Option
|
||||
enabledBuiltInMetrics bool
|
||||
}
|
||||
|
||||
// IsBuiltInMetricsEnabled returns whether the builtin metrics is enabled.
|
||||
func (cfg providerConfig) IsBuiltInMetricsEnabled() bool {
|
||||
return cfg.enabledBuiltInMetrics
|
||||
}
|
||||
|
||||
// MetricOptions converts and returns the providerConfig as metrics options.
|
||||
func (cfg providerConfig) MetricOptions() []metric.Option {
|
||||
var metricOptions = make([]metric.Option, 0)
|
||||
if cfg.viewOption != nil {
|
||||
metricOptions = append(metricOptions, cfg.viewOption)
|
||||
}
|
||||
if cfg.readerOption != nil {
|
||||
metricOptions = append(metricOptions, cfg.readerOption)
|
||||
}
|
||||
if cfg.resourceOption != nil {
|
||||
metricOptions = append(metricOptions, cfg.resourceOption)
|
||||
}
|
||||
return metricOptions
|
||||
}
|
||||
|
||||
// WithBuiltInMetrics enables builtin metrics.
|
||||
func WithBuiltInMetrics() Option {
|
||||
return optionFunc(func(cfg providerConfig) providerConfig {
|
||||
cfg.enabledBuiltInMetrics = true
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
// WithResource associates a Resource with a MeterProvider. This Resource
|
||||
// represents the entity producing telemetry and is associated with all Meters
|
||||
// the MeterProvider will create.
|
||||
func WithResource(res *resource.Resource) Option {
|
||||
return optionFunc(func(cfg providerConfig) providerConfig {
|
||||
cfg.resourceOption = metric.WithResource(res)
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
// WithReader associates Reader r with a MeterProvider.
|
||||
//
|
||||
// By default, if this option is not used, the MeterProvider will perform no
|
||||
// operations; no data will be exported without a Reader.
|
||||
func WithReader(reader metric.Reader) Option {
|
||||
return optionFunc(func(cfg providerConfig) providerConfig {
|
||||
if reader == nil {
|
||||
return cfg
|
||||
}
|
||||
cfg.readerOption = metric.WithReader(reader)
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
// WithView associates views a MeterProvider.
|
||||
//
|
||||
// Views are appended to existing ones in a MeterProvider if this option is
|
||||
// used multiple times.
|
||||
//
|
||||
// By default, if this option is not used, the MeterProvider will use the
|
||||
// default view.
|
||||
func WithView(views ...metric.View) Option {
|
||||
return optionFunc(func(cfg providerConfig) providerConfig {
|
||||
cfg.viewOption = metric.WithView(views...)
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
34
contrib/metric/otelmetric/otelmetric_prometheus.go
Normal file
34
contrib/metric/otelmetric/otelmetric_prometheus.go
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/collectors"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
// PrometheusHandler returns the http handler for prometheus metrics exporting.
|
||||
func PrometheusHandler(r *ghttp.Request) {
|
||||
// Remove all builtin metrics that are produced by prometheus client.
|
||||
prometheus.Unregister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
|
||||
prometheus.Unregister(collectors.NewGoCollector())
|
||||
|
||||
handler := promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{})
|
||||
handler.ServeHTTP(r.Response.Writer, r.Request)
|
||||
}
|
||||
|
||||
// StartPrometheusMetricsServer starts running a http server for metrics exporting.
|
||||
func StartPrometheusMetricsServer(port int, path string) {
|
||||
s := g.Server()
|
||||
s.BindHandler(path, PrometheusHandler)
|
||||
s.SetPort(port)
|
||||
s.Run()
|
||||
}
|
||||
151
contrib/metric/otelmetric/otelmetric_provider.go
Normal file
151
contrib/metric/otelmetric/otelmetric_provider.go
Normal file
@ -0,0 +1,151 @@
|
||||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package otelmetric
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/contrib/instrumentation/runtime"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
"go.opentelemetry.io/otel/sdk/metric"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gmetric"
|
||||
)
|
||||
|
||||
// localProvider implements interface gmetric.Provider.
|
||||
type localProvider struct {
|
||||
*metric.MeterProvider
|
||||
}
|
||||
|
||||
// newProvider creates and returns an object that implements gmetric.Provider.
|
||||
// DO NOT set this as global provider internally.
|
||||
func newProvider(options ...Option) (gmetric.Provider, error) {
|
||||
// TODO global logger set for otel.
|
||||
// otel.SetLogger()
|
||||
|
||||
var (
|
||||
err error
|
||||
metrics = gmetric.GetAllMetrics()
|
||||
builtinViews = createViewsForBuiltInMetrics()
|
||||
callbacks = gmetric.GetRegisteredCallbacks()
|
||||
)
|
||||
options = append(options, WithView(builtinViews...))
|
||||
|
||||
var (
|
||||
config = newProviderConfigByOptions(options)
|
||||
provider = &localProvider{
|
||||
// MeterProvider is the core object that can create otel metrics.
|
||||
MeterProvider: metric.NewMeterProvider(config.MetricOptions()...),
|
||||
}
|
||||
)
|
||||
|
||||
if err = provider.initializeMetrics(metrics); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = provider.initializeCallback(callbacks); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// builtin metrics: golang.
|
||||
if config.IsBuiltInMetricsEnabled() {
|
||||
err = runtime.Start(
|
||||
runtime.WithMinimumReadMemStatsInterval(time.Second),
|
||||
runtime.WithMeterProvider(provider),
|
||||
)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, gerror.WrapCode(
|
||||
gcode.CodeInternalError, err, `start built-in runtime metrics failed`,
|
||||
)
|
||||
}
|
||||
|
||||
return provider, nil
|
||||
}
|
||||
|
||||
// SetAsGlobal sets current provider as global meter provider for current process,
|
||||
// which makes the following metrics creating on this Provider, especially the metrics created in runtime.
|
||||
func (l *localProvider) SetAsGlobal() {
|
||||
gmetric.SetGlobalProvider(l)
|
||||
otel.SetMeterProvider(l)
|
||||
}
|
||||
|
||||
// MeterPerformer creates and returns a MeterPerformer.
|
||||
// A Performer can produce types of Metric performer.
|
||||
func (l *localProvider) MeterPerformer(option gmetric.MeterOption) gmetric.MeterPerformer {
|
||||
return newMeterPerformer(l.MeterProvider, option)
|
||||
}
|
||||
|
||||
// createViewsForBuiltInMetrics creates and returns views for builtin metrics.
|
||||
func createViewsForBuiltInMetrics() []metric.View {
|
||||
var views = make([]metric.View, 0)
|
||||
views = append(views, metric.NewView(
|
||||
metric.Instrument{
|
||||
Name: "process.runtime.go.gc.pause_ns",
|
||||
Scope: instrumentation.Scope{
|
||||
Name: runtime.ScopeName,
|
||||
Version: runtime.Version(),
|
||||
},
|
||||
},
|
||||
metric.Stream{
|
||||
Aggregation: metric.AggregationExplicitBucketHistogram{
|
||||
Boundaries: []float64{
|
||||
500, 1000, 5000, 10000, 50000, 100000, 500000, 1000000,
|
||||
},
|
||||
},
|
||||
},
|
||||
))
|
||||
views = append(views, metric.NewView(
|
||||
metric.Instrument{
|
||||
Name: "runtime.uptime",
|
||||
Scope: instrumentation.Scope{
|
||||
Name: runtime.ScopeName,
|
||||
Version: runtime.Version(),
|
||||
},
|
||||
},
|
||||
metric.Stream{
|
||||
Name: "process.runtime.uptime",
|
||||
},
|
||||
))
|
||||
return views
|
||||
}
|
||||
|
||||
// initializeMetrics initializes all metrics in provider creating.
|
||||
// The initialization replaces the underlying metric performer using noop-performer with truly performer
|
||||
// that implements operations for types of metric.
|
||||
func (l *localProvider) initializeMetrics(metrics []gmetric.Metric) error {
|
||||
for _, m := range metrics {
|
||||
if initializer, ok := m.(gmetric.MetricInitializer); ok {
|
||||
if err := initializer.Init(l); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *localProvider) initializeCallback(callbackItems []gmetric.CallbackItem) error {
|
||||
var err error
|
||||
for _, callbackItem := range callbackItems {
|
||||
if callbackItem.Provider != nil {
|
||||
continue
|
||||
}
|
||||
if len(callbackItem.Metrics) == 0 {
|
||||
continue
|
||||
}
|
||||
callbackItem.Provider = l
|
||||
if err = l.MeterPerformer(callbackItem.MeterOption).RegisterCallback(
|
||||
callbackItem.Callback, callbackItem.Metrics...,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user