Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update go version and mysql pkg version #49

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/compatibility-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20.0'
go-version-file: 'example_code/go/go.mod'
- name: Run test on ${{ matrix.os }}
run: |
cd example_code/go
Expand All @@ -358,7 +358,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20.0'
go-version-file: 'example_code/gorm/go.mod'
- name: Run test on ${{ matrix.os }}
run: |
cd example_code/gorm
Expand Down
13 changes: 9 additions & 4 deletions example_code/go/ConnectTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"crypto/tls"
"database/sql"
"fmt"
"github.com/go-sql-driver/mysql"
"log"
"net/url"
"os"

"github.com/go-sql-driver/mysql"
)

func main() {
Expand All @@ -20,16 +22,19 @@ func main() {
ServerName: host,
})

db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:4000)/test?tls=tidb&connectionAttributes=program_name:pingcap%2Fserverless-test", user, password, host))
db, err := sql.Open("mysql", fmt.Sprintf(
"%s:%s@tcp(%s:4000)/test?tls=tidb&connectionAttributes=%s",
user, password, host, url.QueryEscape("program_name:pingcap/serverless-test")),
)
if err != nil {
log.Fatal("failed to connect database", err)
log.Fatal("failed to connect database -> ", err)
}
defer db.Close()

var dbName string
err = db.QueryRow("SELECT DATABASE();").Scan(&dbName)
if err != nil {
log.Fatal("failed to execute query", err)
log.Fatal("failed to execute query -> ", err)
}
fmt.Println(dbName)
}
4 changes: 2 additions & 2 deletions example_code/go/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module tls

go 1.20
go 1.21

require github.com/go-sql-driver/mysql v1.7.2-0.20230713085235-0b18dac46f7f
require github.com/go-sql-driver/mysql v1.7.2-0.20231114111717-b2e2ccbf1656
4 changes: 2 additions & 2 deletions example_code/go/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/go-sql-driver/mysql v1.7.2-0.20230713085235-0b18dac46f7f h1:4+t8Qb99xUG/Ea00cQAiQl+gsjpK8ZYtAO8E76gRzQI=
github.com/go-sql-driver/mysql v1.7.2-0.20230713085235-0b18dac46f7f/go.mod h1:6gYm/zDt3ahdnMVTPeT/LfoBFsws1qZm5yI6FmVjB14=
github.com/go-sql-driver/mysql v1.7.2-0.20231114111717-b2e2ccbf1656 h1:LSeszcr8gjrxgKhKy/xvlX4nFgCtmqKM9+R/8zgIWUI=
github.com/go-sql-driver/mysql v1.7.2-0.20231114111717-b2e2ccbf1656/go.mod h1:6gYm/zDt3ahdnMVTPeT/LfoBFsws1qZm5yI6FmVjB14=
11 changes: 8 additions & 3 deletions example_code/gorm/ConnectTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package main
import (
"crypto/tls"
"fmt"
"log"
"net/url"
"os"

"github.com/go-sql-driver/mysql"
gormmysql "gorm.io/driver/mysql"
"gorm.io/gorm"
"log"
"os"
)

func main() {
Expand All @@ -19,7 +21,10 @@ func main() {
MinVersion: tls.VersionTLS12,
ServerName: host,
})
dsn := fmt.Sprintf("%s:%s@tcp(%s:4000)/test?tls=tidb&connectionAttributes=program_name:pingcap%2Fserverless-test", user, password, host)
dsn := fmt.Sprintf(
"%s:%s@tcp(%s:4000)/test?tls=tidb&connectionAttributes=%s",
user, password, host, url.QueryEscape("program_name:pingcap/serverless-test"),
)

db, err := gorm.Open(gormmysql.Open(dsn), &gorm.Config{})
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions example_code/gorm/go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module tls

go 1.20
go 1.21

require (
github.com/go-sql-driver/mysql v1.7.2-0.20230713085235-0b18dac46f7f
gorm.io/driver/mysql v1.4.4
gorm.io/gorm v1.24.2
github.com/go-sql-driver/mysql v1.7.2-0.20231114111717-b2e2ccbf1656
gorm.io/driver/mysql v1.5.2
gorm.io/gorm v1.25.5
)

require (
Expand Down
18 changes: 8 additions & 10 deletions example_code/gorm/go.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.7.2-0.20230713085235-0b18dac46f7f h1:4+t8Qb99xUG/Ea00cQAiQl+gsjpK8ZYtAO8E76gRzQI=
github.com/go-sql-driver/mysql v1.7.2-0.20230713085235-0b18dac46f7f/go.mod h1:6gYm/zDt3ahdnMVTPeT/LfoBFsws1qZm5yI6FmVjB14=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.7.2-0.20231114111717-b2e2ccbf1656 h1:LSeszcr8gjrxgKhKy/xvlX4nFgCtmqKM9+R/8zgIWUI=
github.com/go-sql-driver/mysql v1.7.2-0.20231114111717-b2e2ccbf1656/go.mod h1:6gYm/zDt3ahdnMVTPeT/LfoBFsws1qZm5yI6FmVjB14=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
gorm.io/driver/mysql v1.4.4 h1:MX0K9Qvy0Na4o7qSC/YI7XxqUw5KDw01umqgID+svdQ=
gorm.io/driver/mysql v1.4.4/go.mod h1:BCg8cKI+R0j/rZRQxeKis/forqRwRSYOR8OM3Wo6hOM=
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.24.2 h1:9wR6CFD+G8nOusLdvkZelOEhpJVwwHzpQOUM+REd6U0=
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/driver/mysql v1.5.2 h1:QC2HRskSE75wBuOxe0+iCkyJZ+RqpudsQtqkp+IMuXs=
gorm.io/driver/mysql v1.5.2/go.mod h1:pQLhh1Ut/WUAySdTHwBpBv6+JKcj+ua4ZFx1QQTBzb8=
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls=
gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
Loading