Skip to content

mariojuzar/fleet-inventory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Imperial Fleet Inventory

Contributing

Please refer to each project's style and contribution guidelines for submitting patches and additions. In general, we follow the "clone-and-pull" Git workflow.

  1. Clone the project to your own machine
  2. Commit changes to your own branch
  3. Push your work back up to your branch
  4. Submit a Merge Request so that anyone can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a merge request!

Getting started

Requirements

  • go version >= 1.21
  • Makefile
  • mockery v2.32.0
  • swag

Usage

Config

Please set your env variable. You can take example from .env.example

API Server

running http server using

make run-api

or go command

go run main.go serve-http

Mockery

Install the Mockery

https://vektra.github.io/mockery/latest/installation/#go-install

$ go install github.com/vektra/mockery/v2@v2.32.0

Check version

$ mockery --version
16 Jul 23 19:16 WIB INF couldn't read any config file version=v2.32.0
16 Jul 23 19:16 WIB INF Starting mockery dry-run=false version=v2.32.0
16 Jul 23 19:16 WIB INF Using config:  dry-run=false version=v2.32.0
v2.32.0

Remock Interface

You will need mock interface for unit test. You can run command to make mock for all required directories:

make remock

Swagger

Install the CLI

$ go get -u github.com/swaggo/swag/cmd/swag@v1.8.12

Register on bash or zsh

$ sudo nano ~/.zshrc

// ...
export PATH=$(go env GOPATH)/bin:$PATH

// save 
$ source ~/.zshrc

Access the swagger docs

http://{HOST}/docs/index.html

update swagger docs file manually by running command

make swag-init

accessing swagger docs using

http://localhost:8900/docs/index.html

enable/disable swagger docs by configuration properties, default is enabled

DB Migration

Reference:

Install Go Migrate

$ go install -tags "mysql" github.com/golang-migrate/migrate/v4/cmd/migrate@latest

Create Migration File

$ migrate create -ext sql -dir db/migrations [name_of_migration_file]

Migrate up

$ migrate -database "mysql://user:password@tcp(host:port)/dbname?query" -path db/migrations up

Migrate down

$ migrate -database "mysql://user:password@tcp(host:port)/dbname?query" -path db/migrations down

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published