GO CRUD
Simple CRUD RESTful API written in Go and MySQL for RDBMS
Prerequisites
Install Go v 1.11+
Please check the Official Golang Documentation for installation.
Install SQL-Migrate
go get -v github.com/rubenv/sql-migrate/...
Install Mockery
go get github.com/vektra/mockery/.../
Install MySQL on Docker
docker pull mysql
docker run --name <countainer_name> --restart=always -p 3306:3306 -e MYSQL_ROOT_PASSWORD=<mysql_password> -d mysql
Installation
Clone this repository
git clone git@github.com:andisis/gocrud.git
# Switch to the repository folder
cd gocrud
Copy the .env.example to .env
cp .env.example .env
Make the required configuration changes in the .env file.
Copy the dbconfig.yml.example to dbconfig.yml
cp dbconfig.yml.example dbconfig.yml
Make the required configuration changes in the dbconfig.yml file.
Run DB Migration
make migrate
Run Application
make run
Install on Docker
Create docker image
make image
Create docker container
docker run --name <container_name> --rm -d --env-file <path/to/your/.env> -p 8080:8000 gocrud:latest
Unit Testing
make test
If you want to see coverage in an HTML presentation (after the test) just run:
make coverage
Folders
cmd/gocrud - Contains main.go.
migrations - Contains DB migrator.
src/api - Contains packages which are specific to your project.
src/database/config - Contains database configuration.
src/database/query - Contains database query.
src/model - Contains any object structure.
src/router - Contains router for the project.
bin - Contains binary files from the application.
Reference
Contributing
When contributing to this repository, please note we have a code standards, please follow it in all your interactions with the project.
Steps to contribute
- Fork this repository.
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Submit pull request.
Note :
Deployment
Coming soon