From 2b1ac2ac196084e156733c3a550ba1007a5240a7 Mon Sep 17 00:00:00 2001 From: dingbo Date: Wed, 15 Jun 2022 16:47:35 +0800 Subject: [PATCH] docs: connect go --- docs/examples/go/connectexample/main.go | 33 +++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/docs/examples/go/connectexample/main.go b/docs/examples/go/connectexample/main.go index d704468ce8..00736fd019 100644 --- a/docs/examples/go/connectexample/main.go +++ b/docs/examples/go/connectexample/main.go @@ -1,24 +1,25 @@ package main import ( - "database/sql" - "fmt" - "os" + "database/sql" + "fmt" + "os" - _ "github.com/taosdata/driver-go/v2/taosRestful" + _ "github.com/taosdata/driver-go/v2/taosRestful" ) func main() { - dsn := os.Getenv("TDENGINE_GO_DSN") - taos, err := sql.Open("taosRestful", dsn) - if err != nil { - fmt.Println("failed to connect TDengine, err:", err) - return - } - _, err = taos.Exec("select server_version()") - if err != nil { - fmt.Println(err) - } - fmt.Println("connect success") - defer taos.Close() + dsn := os.Getenv("TDENGINE_GO_DSN") + taos, err := sql.Open("taosRestful", dsn) + if err != nil { + fmt.Println(err) + return + } + _, err = taos.Query("select server_version()") + if err != nil { + fmt.Println(err) + return + } + fmt.Println("connect success") + defer taos.Close() } -- GitLab