This repository has been archived by the owner on Oct 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (47 loc) · 1.65 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
.PHONY: format
format:
@#go install golang.org/x/tools/cmd/goimports@latest
@#goimports -local "github.com/hodlgap/captive-portal" -w .
@go install -v github.com/incu6us/goimports-reviser/v3@latest
@goimports-reviser -rm-unused \
-company-prefixes 'github.com/hodlgap' \
-excludes 'db' \
-project-name 'github.com/hodlgap/captive-portal' \
-format \
./...
@gofmt -s -w .
@go mod tidy
.PHONY: lint
lint:
@golangci-lint run -v ./...
.PHONY: test
test:
@go install github.com/rakyll/gotest@latest
@gotest -race -cover -v ./...
.PHONY: update
update:
@go get -u all
@go mod tidy
.PHONY: generate
generate:
@go install go.uber.org/mock/mockgen@latest
@go generate ./...
.PHONY: models
models:
@go install github.com/volatiletech/sqlboiler/v4@latest
@go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest
sqlboiler psql -c sqlboiler.toml \
--templates ${GOPATH}/pkg/mod/github.com/volatiletech/sqlboiler/*/templates/main \
--templates ${GOPATH}/pkg/mod/github.com/volatiletech/sqlboiler/*/drivers/sqlboiler-psql/driver/override/main \
--templates db/templates
.PHONY: dump-db
dump-db:
@# This dumps your local postgres to db/schema.sql
@PGPASSWORD=example pg_dump --no-owner --schema-only --no-privileges --host=localhost --username=postgres --dbname=captive-portal > db/schema.sql
echo "db/schema.sql"
.PHONY: restore-db
restore-db:
# This restores your local postgres to db/schema.sql
#PGPASSWORD=example psql --host=localhost --username=postgres --dbname=captive-portal -c "drop database if exists \"captive-portal\";"
@PGPASSWORD=example psql -h localhost -U postgres -d captive-portal < db/schema.sql
echo "Completed"