It's an example for Golang and TiDB. Contains subproject:
We use different frameworks or libraries to implement similar processes to reflect the solution for connecting to TiDB in different environments
This is a process about the game, each player has two attributes,
coins
and goods
, and each player has their own unique id
as an identifier.
Players can trade with each other, provided that the coins
and goods
are sufficient
The process is as follows:
- Create a player
- Create some players
- Read players amount
- Read some players attributes
- Two player trade with insufficient coins or goods
- Two player trade with sufficient coins or goods
- Golang SDK
- mycli
It's an example used gorm to connect TiDB.
-
Makefile(recommend)
- Run
make gorm-example
- Run
-
Manual
- Into
gorm
- Run
go build -o bin/gorm-example
- Run
./bin/gorm-example
- Into
gorm-example expected output
It's an example used go-sql-driver/mysql to connect TiDB.
-
Makefile(recommend)
- Run
make sql-driver-example
- Run
-
Manual
- Run create table sql in your TiDB
- Into
sqldriver
- Run
go build -o bin/sql-driver-example
- Run
./bin/sql-driver-example
go-sql-driver/mysql expected output
It's an example service used gorm to connect TiDB. Provide a group of HTTP Restful interface.
-
Makefile(recommend)
- First terminal
- Run
make http-example
- Run
- Second terminal
- Run
make request
- Run
- You can quit first terminal to stop service
- First terminal
-
Manual
- Into
http
- Run
go build -o bin/http
- Run
./bin/http
- Request:
- Option 1 (recommend):
- Input Request Collection to Postman
- Request by Postman application
- Option 2:
- Using script to request. It's based on
curl
- Using script to request. It's based on
- Option 3:
- Request HTTP Restful interface by other way
- Option 1 (recommend):
- Into
- request expected output
- service expected output