fomapi

command module
v0.0.0-...-ded5120 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: MIT Imports: 6 Imported by: 0

README

Fomapi

Setup local development

Install tools
  • Docker desktop

  • TablePlus

  • Golang

  • Migrate

    $ curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | apt-key add -
    $ echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ focal main" > /etc/apt/sources.list.d/migrate.list
    $ apt-get update
    $ apt-get install -y migrate
    
  • Sqlc

    Ubuntu

    sudo snap install sqlc
    

    Docker

    docker pull kjconroy/sqlc
    

    Run sqlc using docker run:

    docker run --rm -v $(pwd):/src -w /src kjconroy/sqlc generate
    
  • Gomock

    go install github.com/golang/mock/mockgen@v1.6.0
    
Setup infrastructure
  • Start postgres container:

    make postgres
    
  • Create database:

    make createdb
    
  • Run db migration up all versions:

    make migrateup
    
  • Run db migration down all versions:

    make migratedown
    
How to generate code
  • Generate SQL CRUD with sqlc:

    make sqlc
    
  • Generate DB mock with gomock:

    make mock
    
  • Create a new db migration:

    migrate create -ext sql -dir db/migration -seq <migration_name>
    
How to run
  • Run server:

    make server
    
  • Run test:

    make test
    

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
db
mock
Package mockdb is a generated GoMock package.
Package mockdb is a generated GoMock package.

Jump to

Keyboard shortcuts

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