Skip to content

pscn/go-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-api Flavor API

Loosely based on go-vue-starter

running with docker

Install dep to manage the go dependencies and fetch them:

go get -u github.com/golang/dep/cmd/dep
dep ensure

Then run docker-compose like:

yes | docker-compose rm && docker-compose up --build

If you want to run the locally build go app do:

go build && ./go-api -l 2999

This will listen on port 2999 alongside an already running docker container.

development

Install dependencies:

go get -u ./...

db migration

Go get the migrate CLI.

go get -tags 'postgres' -u github.com/golang-migrate/migrate/cmd/migrate

Run the migrations:

migrate -source file://migrations -database postgres://gusta:changeme@localhost:5432/gusta?sslmode=disable up

Create a new migration (e. g. for recipes). This will create up & down files for recipes in the migrations directory.

cd migrations
migrate create  -ext sql -dir . -seq -digits 4 recipes

To drop everything and start new do:

migrate -source file://migrations -database postgres://gusta:changeme@localhost:5432/gusta?sslmode=disable drop

Note on the migration package: This will probably not be it. Lots of strange behaviors. E. g. using the above command to create a new migration with -dir migrations/ fails in reading the existing files, because it can not convert the path to int. Too bad.

About

POC for a go REST API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published