A web application boilerplate built with go and clean architecture. Most of this application built by standard libray.
cp app/.env_example app/.env
docker-compose build
docker-compose up
After running docker, you need to execute sql files in app/database/sql.
app
├── database
│   ├── migrations
│   │   └── schema.sql
│   └── seeds
│       └── faker.sql
├── domain
│   ├── post.go
│   └── user.go
├── infrastructure
│   ├── env.go
│   ├── logger.go
│   ├── router.go
│   └── sqlhandler.go
├── interfaces
│   ├── post_controller.go
│   ├── post_repository.go
│   ├── sqlhandler.go
│   ├── user_controller.go
│   └── user_repository.go
├── log
│   ├── access.log
│   └── error.log
├── main.go
└── usecases
    ├── logger.go
    ├── post_interactor.go
    ├── post_repository.go
    ├── user_interactor.go
    └── user_repository.go
8 directories, 22 files
| Layer | Directory | 
|---|---|
| Frameworks & Drivers | infrastructure | 
| Interface | interfaces | 
| Usecases | usecases | 
| Entities | domain | 
| ENDPOINT | HTTP Method | Parameters | 
|---|---|---|
| /users | GET | |
| /user | GET | ?id=[int] | 
| /posts | GET | |
| /post | POST | |
| /post | DELETE | ?id=[int] | 
| Controller Method | HTTP Method | Description | 
|---|---|---|
| Index | GET | Display a listing of the resource | 
| Store | POST | Store a newly created resource in storage | 
| Show | GET | Display the specified resource | 
| Update | PUT/PATCH | Update the specified resource in storage | 
| Destroy | DELETE | Remove the specified resource from storage | 
| Repository Method | Description | 
|---|---|
| FindByXX | Returns the entity identified by the given XX | 
| FindAll | Returns all entities | 
| Save | Saves the given entity | 
| SaveByXX | Saves the given entity identified by the given XX | 
| DeleteByXX | Deletes the entity identified by the given XX | 
| Count | Returns the number of entities | 
| ExistsBy | Indicates whether an entity with the given ID exists | 
cf. Spring Data JPA - Reference Documentation
I have no tests because of my laziness, but I will prepare tests in github - gobel-api which is a my more practical clean architecture application with golang.
- github - manuelkiessling/go-cleanarchitecture
- github - rymccue/golang-standard-lib-rest-api
- github - hirotakan/go-cleanarchitecture-sample
- Recruit Technologies - Go言語とDependency Injection
- Clean ArchitectureでAPI Serverを構築してみる
- github - ponzu-cms/ponzu
- クリーンアーキテクチャの書籍を読んだのでAPIサーバを実装してみた
- Go × Clean Architectureのサンプル実装
- Uncle Bob – Payroll Case Study (A full implementation)
