https://github.com/moemoe89/go-grpc-server-tisa
👴 This repo for practicing gRPC server using Golang, PostgreSQL, Docker, Travis CI and CodeCov
https://github.com/moemoe89/go-grpc-server-tisa
codecov docker go golang grpc postgresql travis-ci
Last synced: 3 months ago
JSON representation
👴 This repo for practicing gRPC server using Golang, PostgreSQL, Docker, Travis CI and CodeCov
- Host: GitHub
- URL: https://github.com/moemoe89/go-grpc-server-tisa
- Owner: moemoe89
- License: mit
- Created: 2020-04-01T07:01:23.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-22T14:57:14.000Z (almost 6 years ago)
- Last Synced: 2025-03-13T20:28:54.440Z (over 1 year ago)
- Topics: codecov, docker, go, golang, grpc, postgresql, travis-ci
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/moemoe89/go-grpc-server-tisa)
[](https://codecov.io/gh/moemoe89/go-grpc-server-tisa)
[](https://goreportcard.com/report/github.com/moemoe89/go-grpc-server-tisa)
# GO-GRPC-SERVER-TISA #
Practicing GRPC Server using Golang as Programming Language, PostgreSQL as Database
## Directory structure
Your project directory structure should look like this
```
+ your_gopath/
|
+--+ src/github.com/moemoe89
| |
| +--+ go-grpc-server-tisa/
| |
| +--+ main.go
| + api/
| + routers/
| + ... any other source code
|
+--+ bin/
| |
| +-- ... executable file
|
+--+ pkg/
|
+-- ... all dependency_library required
```
## Setup and Build
* Setup Golang
* Setup PostgreSQL
* Setup BloomRPC
* Under `$GOPATH`, do the following command :
```
$ mkdir -p src/github.com/moemoe89
$ cd src/github.com/moemoe89
$ git clone
$ mv go-grpc-server-tisa
```
## Running Migration
* Copy `config-sample.json` to `config.json` and changes the value based on your configurations.
* Create PostgreSQL database for example named `simple_api` and do migration with `Goose`
* Change database configuration on dbconf.yml like `dialect` and `dsn` for each environtment
* Do the following command
```
$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ goose -env=development up
```
## Running Application with Makefile
Make config file for local :
```
$ cp config-sample.json config-local.json
```
Build
```
$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make build
```
Run
```
$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make run
```
Stop
```
$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make stop
```
Make config file for docker :
```
$ cp config-sample.json config-docker.json
```
Docker Build
```
$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make docker-build
```
Docker Up
```
$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make docker-up
```
Docker Down
```
$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make docker-down
```
## How to Run with Docker
Make config file for docker :
```
$ cp config-sample.json config.json
```
Build
```
$ docker-compose build
```
Run
```
$ docker-compose up
```
Stop
```
$ docker-compose down
```
## How to Test gRPC
* Open BloomRPC
* Import proto file
* Fill server address & port
* Do testing
## How to Run Unit Test
Run
```
$ go test ./...
```
Run with cover
```
$ go test ./... -cover
```
Run with HTML output
```
$ go test ./... -coverprofile=c.out && go tool cover -html=c.out
```
## Reference
Thanks to this medium [link](https://toolbox.kurio.co.id/implementing-grpc-service-in-golang-afb9e05c0064) for sharing the great article
## License
MIT