Golang Gin + Angular 6 Web Application
Technologies
Starter project template using the following libraries/frameworks:
Services for CI & CD:
Get project from Github
To get the project, you need to install Go and set your Go workspace (i.e. $GOPATH
) first.
$ go get github.com/app8izer/go-gin-ng6-starter
Alternatively, use git to clone the project:
$ git clone https://github.com/app8izer/go-gin-ng6-starter.git
Install Golang Dependencies via govendor
If not yet installed, install govendor via:
$ go get -u github.com/kardianos/govendor
To install the golang dependencies, run
$ govendor sync
in root of project.
Install Angular Dependencies via npm/yarn
If not yet installed, install node + npm/yarn, e.g. for Mac OS run
$ brew install yarn
which will also install Node.js if it is not already installed.
To install the Angular dependencies, run
$ cd ./frontend
$ yarn install
in root of project.
Install Protobuf Compiler (protoc)
If not yet installed, install protoc, e.g. for Mac OS, run
$ brew install protobuf
and for the Go protocol buffers plugin:
$ go get -u github.com/golang/protobuf/protoc-gen-go
$ go get -u github.com/favadi/protoc-go-inject-tag
The compiler plugin protoc-gen-go
will be installed in $GOBIN
, defaulting to $GOPATH/bin
.
It must be in your $PATH
for the protocol compiler protoc to find it.
Assuming you have run yarn install
before (see above), which installs the protobuf.js
dependency continue with the compilation as follows.
To compile the schema to Go and Typescript sources run
$ cd ./proto
$ sh ./compile_proto.sh
in root of project.
Development Setup
To start the application with PostgreSQL database, Golang backend, and Angular frontend, the following steps are required.
Database: PostgreSQL
Run
$ docker-compose -f docker-compose.dev.yml
in root of project directory.
This will fire up a database listening on port 5432
of your localhost
.
Backend: Gin Gonic
To start the backend server on port 8080
run
$ cd ./backend
$ go run main.go
in root of project directory.
Frontend: Angular
To start the frontend server on port 4200
run
$ cd ./frontend
$ yarn run dev
in root of project directory.