GitHub Action Tests | CodeCov |
---|---|
English | 简体中文
- 1. Introduction
- 2. Get the Driver
- 3. Documentation
- 4. Prerequisites
- 5. Build
- 6. Testing
- 7. Submitting Issues
- 8. Submitting PRs
- 9. References
- 10. License
driver-go
is the official Go language connector for TDengine. It implements the Go language database/sql
interface,
allowing Go developers to create applications that interact with TDengine clusters.
- Native Connection: Establishes a connection directly with the server program taosd through the client driver taosc. This method requires the client driver taosc and the server taosd to be of the same version.
- REST Connection: Establishes a connection with taosd through the REST API provided by the taosAdapter component. This method only supports executing SQL.
- WebSocket Connection: Establishes a connection with taosd through the WebSocket API provided by the taosAdapter component, without relying on the TDengine client driver.
We recommend using the WebSocket connection method. For detailed instructions, please refer to: Connection Methods.
- The platforms supported by the native connection are consistent with those supported by the TDengine client driver.
- WebSocket/REST connections support all platforms that can run Go.
Import the Driver into the Project
import (
"database/sql"
_ "github.com/taosdata/driver-go/v3/taosSql"
)
To manage dependencies using go mod
:
go mod tidy
Or, you can directly install the driver with go get
:
go get github.com/taosdata/driver-go/v3/taosSql
- For development examples, see Developer Guide, which includes examples of data writing, querying, schemaless writing, parameter binding, and data subscription.
- For other reference information, see Reference Manual, which includes version history, data types, example programs, API descriptions, and FAQs.
- Go 1.14 or above and enable CGO with
export CGO_ENABLED=1
. - TDengine has been deployed locally. For detailed steps, please refer to Deploy Server, and taosd and taosAdapter have been started.
After writing an example program, use go build
to build the program.
- Before running tests, ensure that the TDengine server is installed and that
taosd
andtaosAdapter
are running. The database should be empty. - In the project directory, run
go test ./...
to execute the tests. The tests will connect to the local TDengine server and taosAdapter for testing. - The output result
PASS
means the test passed, whileFAIL
means the test failed. For detailed information, rungo test -v ./...
.
Add test cases to the *_test.go
file to ensure that the test cases cover the new code.
Performance testing is in progress.
We welcome the submission of GitHub Issue. When submitting, please provide the following information:
- Description of the issue and whether it is consistently reproducible
- Driver version
- Connection parameters (excluding server address, username, and password)
- TDengine version
We welcome developers to contribute to this project. Please follow the steps below to submit a PR:
- Fork this project. Please refer to how to fork a repo.
- Create a new branch from the main branch with a meaningful branch name (
git checkout -b my_branch
). - Modify the code, ensure all unit tests pass, and add new unit tests to verify the changes.
- Push the changes to the remote branch (
git push origin my_branch
). - Create a Pull Request on GitHub. Please refer to how to create a pull request.
- After submitting the PR, if the CI passes, you can find your PR on the codecov page to check the coverage.