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

macos 编译失败, tdengine 2.2.0 版本 #251

Open
fishdemon opened this issue Mar 27, 2024 · 3 comments
Open

macos 编译失败, tdengine 2.2.0 版本 #251

fishdemon opened this issue Mar 27, 2024 · 3 comments

Comments

@fishdemon
Copy link

fishdemon commented Mar 27, 2024

采用的官方示例

自编译:

go build -o tdengine-sync main.go
报错
github.com/taosdata/driver-go/v2/wrapper
../../../../../go/pkg/mod/github.com/taosdata/driver-go/[email protected]/wrapper/stmt.go:46:58: could not determine kind of name for C.TAOS_BIND

交叉编译:

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o tdengine-sync main.go
报错
github.com/taosdata/driver-go/v2/wrapper: build constraints exclude all Go files in /Users/aallenma/go/pkg/mod/github.com/taosdata/driver-go/[email protected]/wrapper

不论怎么编译都报错

@fishdemon
Copy link
Author

官方代码:
package main

import (
"database/sql"
"fmt"
_ "github.com/taosdata/driver-go/v2/taosSql"
"time"
)

func main() {
var taosuri = "root:taosdata/tcp(localhost:6030)/"
taos, err := sql.Open("taosSql", taosuri)
if err != nil {
fmt.Println("failed to connect TDengine, err:", err)
return
}
defer taos.Close()
taos.Exec("create database if not exists test")
taos.Exec("use test")
taos.Exec("create table if not exists tb1 (ts timestamp, a int)")
_, err = taos.Exec("insert into tb1 values(now, 0)(now+1s,1)(now+2s,2)(now+3s,3)")
if err != nil {
fmt.Println("failed to insert, err:", err)
return
}
rows, err := taos.Query("select * from tb1")
if err != nil {
fmt.Println("failed to select from table, err:", err)
return
}

defer rows.Close()
for rows.Next() {
	var r struct {
		ts time.Time
		a  int
	}
	err := rows.Scan(&r.ts, &r.a)
	if err != nil {
		fmt.Println("scan error:\n", err)
		return
	}
	fmt.Println(r.ts, r.a)
}

}

@fishdemon
Copy link
Author

请问,你们自己的官方示例都无法通过么

@hellojukay
Copy link

涉及到了 C 库,不要交叉编译。比较麻烦。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants