onepanel/CONTRIBUTING.md
2020-03-17 17:36:01 -07:00

1.4 KiB

Database migrations

Install goose:

go get -u github.com/pressly/goose/cmd/goose

Note: Up migrations are automatically executed when the application is run.

goose -dir db create <name> sql                       # Create migration in db folder
goose -dir db postgres "${DB_DATASOURCE_NAME}" up     # Migrate the DB to the most recent version available
goose -dir db postgres "${DB_DATASOURCE_NAME}" down   # Roll back the version by 1
goose help                                            # See all available commands

gRPC installation

Install gRPC:

go get -u google.golang.org/grpc

Download pre-compiled binaries for your platform(protoc--.zip) from here: https://github.com/google/protobuf/releases

On macOS or Linux:

  • Unzip protoc-<version>-<platform>.zip
  • Move bin/protoc to /usr/local/bin/
  • Move include/google to /usr/local/include

Then use go get -u to download the following packages:

go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go

This will place three binaries in your $GOBIN;

  • protoc-gen-grpc-gateway
  • protoc-gen-swagger
  • protoc-gen-go

Make sure that your $GOBIN is in your $PATH.

API code generation

Generate Go and Swagger APIs:

make api