gocrud

module
v0.0.0-...-98765d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2020 License: MIT

README

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
  1. Fork this repository.
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Submit pull request.

Note :

  • Please make sure to update tests as appropriate.

  • It's recommended to run make test command before submit a pull request.

Deployment

Coming soon

Directories

Path Synopsis
cmd
gocrud command
src

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL