Skip to content

amirhosseinmoayedi/Project-template

Repository files navigation

Template for starting project

  • dockerfile and docker-compose
  • makfile
  • live reloading

used packages

  • viper
  • cobra
  • logrus
  • echo
  • gorm
  • golang-migrate

add command to cobra

cobra-cli add command_name

air package is used for live reloading

install:

go install github.com/cosmtrek/air@latest

change the setting in .air.toml file
run it :

air -c .air.toml

clean_on_exit option will delete the tmp directory on air exit, change it if you don't want to.

create migration

create migration

migrate create -ext sql -dir internall/infrastructure/migration/ -seq init_mg

-seq for sequential, UP file for moving db to new state, DOWN for reverting
apply migration

migrate -path internall/infrastructure/migration/ -database "postgresql://username:password@host:port/database_name?sslmode=disable" -verbose up

rollback

migrate -path internall/infrastructure/migration/ -database "postgresql://username:password@host:port/database_name?sslmode=disable" -verbose down

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published