feat: build, run and test application locally
This commit is contained in:
parent
06100b4209
commit
d2b4bdf324
21
Makefile
Normal file
21
Makefile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
SRC := $(shell find . -name "*.go" | grep -v -e .pb.go -e .pb.micro.go)
|
||||||
|
|
||||||
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
|
ifneq (,$(wildcard ./.env))
|
||||||
|
include .env
|
||||||
|
export
|
||||||
|
endif
|
||||||
|
|
||||||
|
fmt: ## Format and fix import order
|
||||||
|
goimports -w -local "e46" $(SRC)
|
||||||
|
|
||||||
|
help: ## Display this help screen
|
||||||
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
||||||
|
build:
|
||||||
|
go build -ldflags "-s -w" -o build/app .
|
||||||
|
|
||||||
|
run:
|
||||||
|
make build-backoffice-gateway
|
||||||
|
./build/app
|
||||||
18
README.md
18
README.md
@ -1,7 +1,7 @@
|
|||||||
# Standard Go Project Template
|
# Standard Go Project Template
|
||||||
This is a template for Go application projects based on [Standard Go Project Layout](https://github.com/golang-standards/project-layout).
|
This is a template for Go application projects based on [Standard Go Project Layout](https://github.com/golang-standards/project-layout).
|
||||||
|
|
||||||
### Build, run and debug application locally
|
### Build, run and test application locally
|
||||||
|
|
||||||
#### Create environment file
|
#### Create environment file
|
||||||
Create and fill environment file from template `.env.dist`
|
Create and fill environment file from template `.env.dist`
|
||||||
@ -9,6 +9,22 @@ Create and fill environment file from template `.env.dist`
|
|||||||
cp .env.dist .env
|
cp .env.dist .env
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Build application
|
||||||
|
``` shell
|
||||||
|
go mod tidy
|
||||||
|
go build -ldflags "-s -w" -o build/app .
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Run application
|
||||||
|
``` shell
|
||||||
|
env $(cat .env|xargs) ./build/app
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Test application
|
||||||
|
``` shell
|
||||||
|
go test ./...
|
||||||
|
```
|
||||||
|
|
||||||
### Build, run and debug application with docker
|
### Build, run and debug application with docker
|
||||||
|
|
||||||
#### Create environment file for docker
|
#### Create environment file for docker
|
||||||
|
|||||||
12
go.mod
12
go.mod
@ -1,8 +1,18 @@
|
|||||||
module golang-app
|
module golang-app
|
||||||
|
|
||||||
go 1.15
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ilyakaznacheev/cleanenv v1.2.5
|
github.com/ilyakaznacheev/cleanenv v1.2.5
|
||||||
github.com/stretchr/testify v1.6.1
|
github.com/stretchr/testify v1.6.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/BurntSushi/toml v0.3.1 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.0 // indirect
|
||||||
|
github.com/joho/godotenv v1.3.0 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
gopkg.in/yaml.v2 v2.2.2 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
||||||
|
olympos.io/encoding/edn v0.0.0-20200308123125-93e3b8dd0e24 // indirect
|
||||||
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user