Coding Challenge
- Golang 19+
- MySQL (or provide details if using a different database)
- Docker
- golang-migrate
- Makefile GNU
Use the following command to init an instance database, and create tables
make init-db
make migrate-up
- MySQL as our database, the schema will be stored in migrations
- We use migrate read migrations from sources and apply them in correct order to a database.
To start the SampleService Server, use the following command:
go run main.go server
- The service will be available at http://localhost:9090
- Swagger docs: http://localhost:9090/swagger/index.html#/
-
GET /users/:id
: Retrieve user information by id -
GET /users/:id/accounts
: Retrieve a list account of user -
GET /accounts/:id
: Retrieve account information by id -
POST /users/register
: Add a new user to the database
{"name": "user name"}
POST /users/:id/accounts
: Add a new account to the database
{"name": "user name"}
To run mock-tests, use the following command:
make mock-test
To run integration-tests, use the following command:
make test-integration
We welcome contributions. To contribute to this project, please follow these steps:
- Fork the repository
- Create a new branch for your feature: git checkout -b feature/your-feature-name
- Commit your changes: git commit -m 'Added a new feature'
- Push to the branch: git push origin feature/your-feature-name
- Create a pull request
Please follow our code of conduct and coding style guidelines.