Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b0971e8f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b0971e8f
编写于
8月 01, 2019
作者:
H
huili
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Fixed dsn parsing for network addr and port by caeret. #214]
上级
52ad125f
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
31 addition
and
23 deletion
+31
-23
src/connector/go/src/taosSql/dsn.go
src/connector/go/src/taosSql/dsn.go
+28
-19
src/connector/go/src/taosSql/taosSqlCgo.go
src/connector/go/src/taosSql/taosSqlCgo.go
+1
-2
tests/examples/go/src/taosapp/taosapp.go
tests/examples/go/src/taosapp/taosapp.go
+2
-2
未找到文件。
src/connector/go/src/taosSql/dsn.go
浏览文件 @
b0971e8f
...
@@ -18,6 +18,7 @@ package taosSql
...
@@ -18,6 +18,7 @@ package taosSql
import
(
import
(
"errors"
"errors"
"net/url"
"net/url"
"strconv"
"strings"
"strings"
"time"
"time"
)
)
...
@@ -25,6 +26,7 @@ import (
...
@@ -25,6 +26,7 @@ import (
var
(
var
(
errInvalidDSNUnescaped
=
errors
.
New
(
"invalid DSN: did you forget to escape a param value?"
)
errInvalidDSNUnescaped
=
errors
.
New
(
"invalid DSN: did you forget to escape a param value?"
)
errInvalidDSNAddr
=
errors
.
New
(
"invalid DSN: network address not terminated (missing closing brace)"
)
errInvalidDSNAddr
=
errors
.
New
(
"invalid DSN: network address not terminated (missing closing brace)"
)
errInvalidDSNPort
=
errors
.
New
(
"invalid DSN: network port is not a valid number"
)
errInvalidDSNNoSlash
=
errors
.
New
(
"invalid DSN: missing the slash separating the database name"
)
errInvalidDSNNoSlash
=
errors
.
New
(
"invalid DSN: missing the slash separating the database name"
)
)
)
...
@@ -100,7 +102,15 @@ func parseDSN(dsn string) (cfg *config, err error) {
...
@@ -100,7 +102,15 @@ func parseDSN(dsn string) (cfg *config, err error) {
}
}
return
nil
,
errInvalidDSNAddr
return
nil
,
errInvalidDSNAddr
}
}
cfg
.
addr
=
dsn
[
k
+
1
:
i
-
1
]
strs
:=
strings
.
Split
(
dsn
[
k
+
1
:
i
-
1
],
":"
)
if
len
(
strs
)
==
1
{
return
nil
,
errInvalidDSNAddr
}
cfg
.
addr
=
strs
[
0
]
cfg
.
port
,
err
=
strconv
.
Atoi
(
strs
[
1
])
if
err
!=
nil
{
return
nil
,
errInvalidDSNPort
}
break
break
}
}
}
}
...
@@ -190,4 +200,3 @@ func parseDSNParams(cfg *config, params string) (err error) {
...
@@ -190,4 +200,3 @@ func parseDSNParams(cfg *config, params string) (err error) {
return
return
}
}
src/connector/go/src/taosSql/taosSqlCgo.go
浏览文件 @
b0971e8f
...
@@ -32,9 +32,8 @@ import (
...
@@ -32,9 +32,8 @@ import (
func
(
mc
*
taosConn
)
taosConnect
(
ip
,
user
,
pass
,
db
string
,
port
int
)
(
taos
unsafe
.
Pointer
,
err
error
){
func
(
mc
*
taosConn
)
taosConnect
(
ip
,
user
,
pass
,
db
string
,
port
int
)
(
taos
unsafe
.
Pointer
,
err
error
){
cuser
:=
C
.
CString
(
user
)
cuser
:=
C
.
CString
(
user
)
cpass
:=
C
.
CString
(
pass
)
cpass
:=
C
.
CString
(
pass
)
cip
:=
C
.
CString
(
ip
)
// TODO: Addr : x.x.x.x:port, must process to ip and port format
cip
:=
C
.
CString
(
ip
)
cdb
:=
C
.
CString
(
""
)
cdb
:=
C
.
CString
(
""
)
port
=
0
defer
C
.
free
(
unsafe
.
Pointer
(
cip
))
defer
C
.
free
(
unsafe
.
Pointer
(
cip
))
defer
C
.
free
(
unsafe
.
Pointer
(
cuser
))
defer
C
.
free
(
unsafe
.
Pointer
(
cuser
))
defer
C
.
free
(
unsafe
.
Pointer
(
cpass
))
defer
C
.
free
(
unsafe
.
Pointer
(
cpass
))
...
...
tests/examples/go/src/taosapp/taosapp.go
浏览文件 @
b0971e8f
...
@@ -29,7 +29,7 @@ func main() {
...
@@ -29,7 +29,7 @@ func main() {
fmt
.
Printf
(
"
\n
======== start demo test ========
\n
"
)
fmt
.
Printf
(
"
\n
======== start demo test ========
\n
"
)
// open connect to taos server
// open connect to taos server
db
,
err
:=
sql
.
Open
(
taosDriverName
,
"root:taosdata@/tcp(127.0.0.1)/demodb"
)
db
,
err
:=
sql
.
Open
(
taosDriverName
,
"root:taosdata@/tcp(127.0.0.1
:0
)/demodb"
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"Open database error: %s
\n
"
,
err
)
log
.
Fatalf
(
"Open database error: %s
\n
"
,
err
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录