Setting Up the Go Driver Environment
Obtaining the Driver Package
Download the driver package and its verification package listed in Table 1.
- Verifying the software package integrity on a Linux server:
- Upload the software package and verification package to the same directory on the VM.
- Run the following command to verify the integrity of the software package:
cat GaussDB_driver.zip.sha256 | sha256sum --check
If OK is displayed in the command output, the verification is successful.
GaussDB_driver.zip: OK
- Verifying the software package integrity on a Windows server:
- Press Win+R to open the Run dialog box. Type cmd in the text box and press Enter to open the Command Prompt window.
- Run the following command to obtain the hash value of the driver package:
certutil -hashfile {local_directory_of_the_driver_package}\{driver_package_name} sha256
- Replace {local_directory_of_the_driver_package} with the actual download path, for example, C:\Users.
- Replace {driver_package_name} with the name of the downloaded driver package, for example, GaussDB_driver.zip.
Example: certutil -hashfile C:\Users\GaussDB_driver.zip sha256
- Compare the hash value obtained in 2 with the hash value of the verification package obtained in Table 1.
Environment Class
- Configure the Go environment.
- You need to configure the following parameters in the environment variables:
- GO111MODULE: Set GO111MODULE to on when installing the Go driver by importing a file online. If you do not want to reconstruct the Go mod project, set GO111MODULE to off and manually download the dependency package. The dependency package must be at the same level as the driver root directory and service code.
- GOPROXY: When importing data online, you need to configure the path that contains the Go driver package.
- You can configure other Go environment variables based on your scenario parameters.
Run the go env command to view the Go environment variable configuration result and check whether the Go version is 1.13 or later.
- Install the Go driver.
- Obtain the Go driver package GaussDB-Kernel_Database version number_OS version number_64bit_Go.tar.gz from the driver package. Decompress the package to obtain the Go driver source code package.
- Go to the root path of the Go driver code and run the go mod tidy command to download related dependencies. You need to configure GOPATH=${Path for storing the Go driver dependency package} in the environment variables.
- If the dependencies have been downloaded to the localhost, you can add a line "Replace the Go driver package with the local Go driver package address through replace" to go.mod, indicating that all import Go driver packages in the code are stored in the local path and the dependencies are not downloaded from the proxy.
- When you run the go mod tidy command to download dependencies, some of them may be downloaded as an earlier version. If the earlier version has vulnerabilities, you can change the dependency version in the go.mod file and update the dependency to the version after the vulnerability is fixed to avoid risks.
- The Go driver package provided by the database depends on Go 1.13 or later.
Driver Class
When creating a database connection, you need to enter the database driver name gaussdb.

For details about the Go driver, see Go Driver Compatibility.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot