diff --git a/README.md b/README.md index 2a9447e..0dd6c1e 100644 --- a/README.md +++ b/README.md @@ -24,19 +24,21 @@ import ( ) func main() { - pgdrv.New(&sshql.Dialer{ + dialer := &sshql.Dialer{ Hostname: "sshserver", Port: 22, Username: "remoteuser", Password: "passphraseforauthkey", PrivateKey: "/home/username/.ssh/id_eddsa", - }).Register() + } + pgdrv.New(dialer).Register() db, err := sql.Open(pgdrv.DriverName, "postgres://dbuser:dbpassword@localhost:5432/example?sslmode=disable") if err != nil { fmt.Fprintln(os.Stderr, err) return } + defer dialer.Close() defer db.Close() rows, err := db.Query("SELECT id, name FROM example ORDER BY id") @@ -72,19 +74,21 @@ import ( ) func main() { - mysqldrv.New(&sshql.Dialer{ + dialer := &sshql.Dialer{ Hostname: "sshserver", Port: 22, Username: "remoteuser", Password: "passphraseforauthkey", PrivateKey: "/home/username/.ssh/id_eddsa", - }).RegisterDial() + } + mysqldrv.New(dialer).RegisterDial() db, err := sql.Open("mysql", fmt.Sprintf("dbuser:dbpassword@%s(localhost:3306)/dbname", mysqldrv.DialName)) if err != nil { fmt.Fprintln(os.Stderr, err) return } + defer dialer.Close() defer db.Close() rows, err := db.Query("SELECT id, name FROM example ORDER BY id") diff --git a/mysqldrv/go.mod b/mysqldrv/go.mod index 7e4bea2..0c03cd9 100644 --- a/mysqldrv/go.mod +++ b/mysqldrv/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/go-sql-driver/mysql v1.6.0 github.com/goark/errs v1.1.0 - github.com/goark/sshql v0.1.2 + github.com/goark/sshql v0.1.3 ) require ( diff --git a/mysqldrv/go.sum b/mysqldrv/go.sum index 5840de4..448f583 100644 --- a/mysqldrv/go.sum +++ b/mysqldrv/go.sum @@ -2,8 +2,8 @@ github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfC github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/goark/errs v1.1.0 h1:FKnyw4LVyRADIjM8Nj0Up6r0/y5cfADvZAd1E+tthXE= github.com/goark/errs v1.1.0/go.mod h1:TtaPEoadm2mzqzfXdkkfpN2xuniCFm2q4JH+c1qzaqw= -github.com/goark/sshql v0.1.2 h1:WWGRF9Cz3rzUDz/qDZwyrZN66o840FdaLsTn4KXQDEk= -github.com/goark/sshql v0.1.2/go.mod h1:CKO0diQlHb5BpJMi4mT0MlhA5qqrG3Pg+5b+wi6OtgU= +github.com/goark/sshql v0.1.3 h1:fAzkGTkteiwAtkBroi8YS44V1zCYern5l42MqWGl6Bo= +github.com/goark/sshql v0.1.3/go.mod h1:CKO0diQlHb5BpJMi4mT0MlhA5qqrG3Pg+5b+wi6OtgU= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= diff --git a/pgdrv/go.mod b/pgdrv/go.mod index 41f9758..ca4119e 100644 --- a/pgdrv/go.mod +++ b/pgdrv/go.mod @@ -3,7 +3,7 @@ module github.com/goark/sshql/pgdrv go 1.19 require ( - github.com/goark/sshql v0.1.2 + github.com/goark/sshql v0.1.3 github.com/lib/pq v1.10.7 ) diff --git a/pgdrv/go.sum b/pgdrv/go.sum index 35380cc..7f1081b 100644 --- a/pgdrv/go.sum +++ b/pgdrv/go.sum @@ -1,7 +1,7 @@ github.com/goark/errs v1.1.0 h1:FKnyw4LVyRADIjM8Nj0Up6r0/y5cfADvZAd1E+tthXE= github.com/goark/errs v1.1.0/go.mod h1:TtaPEoadm2mzqzfXdkkfpN2xuniCFm2q4JH+c1qzaqw= -github.com/goark/sshql v0.1.2 h1:WWGRF9Cz3rzUDz/qDZwyrZN66o840FdaLsTn4KXQDEk= -github.com/goark/sshql v0.1.2/go.mod h1:CKO0diQlHb5BpJMi4mT0MlhA5qqrG3Pg+5b+wi6OtgU= +github.com/goark/sshql v0.1.3 h1:fAzkGTkteiwAtkBroi8YS44V1zCYern5l42MqWGl6Bo= +github.com/goark/sshql v0.1.3/go.mod h1:CKO0diQlHb5BpJMi4mT0MlhA5qqrG3Pg+5b+wi6OtgU= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=