Import sql into mysql before you start.
Enter the Sponge UI interface, click on the left menu bar 【SQL】→【Create microservice project】, fill in some parameters to generate a complete microservice project code.
The microservice code is mainly composed of commonly used libraries such as grpc, gorm, go-redis, and also includes grpc client CRUD test code, common service governance function code, build deployment scripts, etc.
Switch to the user directory and run the command:
# Generate pb.go code
make proto
# Compile and start grpc service
make runUse goland IDE to open user service code, enter the internal/service directory, open the teacher_client_test.go file, you can test CRUD methods here, similar to testing CRUD interfaces in swagger interface. Fill in parameters before testing and click the green button to test.
Enter the Sponge UI interface, click on the left menu bar 【Public】→【Generate service CRUD code】, select any number of tables to generate code, then move the generated CRUD code to the grpc service directory to complete batch addition of CURD interfaces in microservices without changing any code.
Switch to user service directory and run command:
# Generate pb.go code
make proto
# Compile and start user service
make runUse goland IDE, enter internal/service directory, open teach_client_test.go and course_client_test.go files to test CRUD methods.
More detailed development microservice documentation https://go-sponge.com/microservice-development-mysql


