Skip to content

Commit 4913e22

Browse files
committed
[update] v.2.0.0 - Clean Architecture
1 parent 2806997 commit 4913e22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+884
-159
lines changed

.circleci/config.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
jobs-references:
2+
go-container: &go-container
3+
docker:
4+
- image: circleci/golang:1.11.9
5+
environment:
6+
GO111MODULE: "on"
7+
working_directory: /go/src/github.com/github.com/bmf-san/go-api-boilerplate/app
8+
setup_go_packages: &setup_go_packages
9+
run:
10+
name: Setup go packages
11+
command: |
12+
go get -u golang.org/x/lint/golint
13+
go get -u github.com/go-sql-driver/mysql
14+
15+
version: 2
16+
jobs:
17+
mod:
18+
<<: *go-container
19+
steps:
20+
- checkout
21+
- *setup_go_packages
22+
- run:
23+
name: "Run mod"
24+
command: |
25+
go mod download
26+
golint:
27+
<<: *go-container
28+
steps:
29+
- checkout
30+
- *setup_go_packages
31+
- run:
32+
name: Run golint
33+
command: golint ./...
34+
vet:
35+
<<: *go-container
36+
steps:
37+
- checkout
38+
- *setup_go_packages
39+
- run:
40+
name: Run vet
41+
command: go vet ./...
42+
test:
43+
<<: *go-container
44+
steps:
45+
- checkout
46+
- *setup_go_packages
47+
- run:
48+
name: Run test
49+
command: go test -v -race ./...
50+
51+
workflows:
52+
version: 2
53+
build:
54+
jobs:
55+
- golint
56+
- vet
57+
- test

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = false
10+
11+
[*.go]
12+
indent_style = tab

.github/CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

.github/CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Contributing
2+
3+
Feel free to contribute ! :)
4+
5+
If you have some questions, requests or something, let me know it.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
**Describe the bug**
8+
A clear and concise description of what the bug is.
9+
10+
**To Reproduce**
11+
Steps to reproduce the behavior:
12+
1. Go to '...'
13+
2. Click on '....'
14+
3. Scroll down to '....'
15+
4. See error
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Screenshots**
21+
If applicable, add screenshots to help explain your problem.
22+
23+
**Desktop (please complete the following information):**
24+
- OS: [e.g. iOS]
25+
- Browser [e.g. chrome, safari]
26+
- Version [e.g. 22]
27+
28+
**Smartphone (please complete the following information):**
29+
- Device: [e.g. iPhone6]
30+
- OS: [e.g. iOS8.1]
31+
- Browser [e.g. stock browser, safari]
32+
- Version [e.g. 22]
33+
34+
**Additional context**
35+
Add any other context about the problem here.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
**Is your feature request related to a problem? Please describe.**
8+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Overview
2+
3+
# Changes
4+
5+
# Impact range
6+
7+
# Operational Requirements
8+
9+
# Related Issue
10+
11+
# Supplement

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
launch.json
12
/app/.env
2-
launch.json
3+
.DS_STORE
4+
/app/go_api_boilerplate
5+
/app/log/*
6+
!/app/log/.gitkeep
7+
.vscode/

README.md

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,81 @@ This is an api boilerplate built with golang.
1212

1313
After running docker, you need to execute sql files in `app/database/sql`.
1414

15-
# References
16-
I refered to this repository.
15+
# Architecture
16+
```
17+
app/
18+
├── database
19+
│   ├── migrations
20+
│   │   └── schema.sql
21+
│   └── seeds
22+
│   └── faker.sql
23+
├── domain
24+
│   ├── post.go
25+
│   └── user.go
26+
├── infrastructure
27+
│   ├── env.go
28+
│   ├── logger.go
29+
│   ├── router.go
30+
│   └── sqlhandler.go
31+
├── interfaces
32+
│   ├── post_controller.go
33+
│   ├── post_repository.go
34+
│   ├── sqlhandler.go
35+
│   ├── user_controller.go
36+
│   └── user_repository.go
37+
├── log
38+
│   ├── access.log
39+
│   └── error.log
40+
├── main.go
41+
├── test.log
42+
└── usecases
43+
├── logger.go
44+
├── post_interactor.go
45+
├── post_repository.go
46+
├── user_interactor.go
47+
└── user_repository.go
48+
```
49+
50+
| Layer | Directory | Sub directory |
51+
|----------------------|----------------|--------------------------------------|
52+
| Frameworks & Drivers | infrastructure | database, router, env |
53+
| Interface | interfaces | controllers, database, repositories |
54+
| Usecases | usecases | repositories |
55+
| Entities | domain | ex. user.go |
56+
57+
# API Document
58+
// TODO: This section will be updated the date when ver.3.0.0 will be released.
59+
60+
61+
# Controller method naming rule
62+
Use these word as prefix.
1763

18-
- [github - rymccue/golang-standard-lib-rest-api](https://github.com/rymccue/golang-standard-lib-rest-api)
64+
- index
65+
- Display a listing of the resource.
66+
- show
67+
- Display the specified resource.
68+
- store
69+
- Store a newly created resource in storage.
70+
- update
71+
- Update the specified resource in storage.
72+
- destory
73+
- Remove the specified resource from storage.
74+
75+
# Repository method naming rule
76+
Use these word as prefix.
77+
78+
- get
79+
- add
80+
- update
81+
- delete
82+
83+
# References
84+
- [github - manuelkiessling/go-cleanarchitecture](https://github.com/manuelkiessling/go-cleanarchitecture)
85+
- [github - rymccue/golang-standard-lib-rest-api](https://github.com/rymccue/golang-standard-lib-rest-api)
86+
- [github - hirotakan/go-cleanarchitecture-sample](https://github.com/hirotakan/go-cleanarchitecture-sample)
87+
- [Recruit Technologies - Go言語とDependency Injection](https://recruit-tech.co.jp/blog/2017/12/11/go_dependency_injection/)
88+
- [Clean ArchitectureでAPI Serverを構築してみる](https://qiita.com/hirotakan/items/698c1f5773a3cca6193e)
89+
- [github - ponzu-cms/ponzu](https://github.com/ponzu-cms/ponzu)
90+
- [クリーンアーキテクチャの書籍を読んだのでAPIサーバを実装してみた](https://qiita.com/yoshinori_hisakawa/items/f934178d4bd476c8da32)
91+
- [Go × Clean Architectureのサンプル実装](http://nakawatch.hatenablog.com/entry/2018/07/11/181453)
92+
- [Uncle Bob – Payroll Case Study (A full implementation)](http://cleancodejava.com/uncle-bob-payroll-case-study-full-implementation/)

app/.realize.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ schema:
66
- name: go-api-boilerplate
77
path: .
88
commands:
9+
build:
10+
status: true
11+
method: go build -o go_api_boilerplate
912
run:
1013
status: true
14+
method: ./go_api_boilerplate
1115
watcher:
1216
extensions:
1317
- go

0 commit comments

Comments
 (0)