# Go Code Examples
## Topics
- Back-end
- Clean Architecture
- CRUD
- Debugging Mode
- [Delve](https://github.com/go-delve/delve)
- Dependency Injection
- Design Patterns
- Docker Compose
- Dockerfile with multi-stage builds
- DTO
- [Gin Web Framework](https://github.com/gin-gonic/gin)
- Golang 1.21
- [Goose](https://github.com/pressly/goose)
- [GORM](https://github.com/go-gorm/gorm)
- Linux
- [Logrus](https://github.com/sirupsen/logrus)
- Makefile
- MVC
- PostgreSQL 16
- RESTful API
- SOLID
- SQL
- [Viper](https://github.com/spf13/viper)
## Installation
1. Clone this repository:
```
git clone git@github.com:d-alejandro/go-code-examples.git
```
2. Go to `go-code-examples` directory:
```
cd go-code-examples
```
3. Create a new .env file:
```
cp .env.example .env
```
4. Download and install `Go` SDK `1.21.6`.
5. Build and run the application:
```
make run
```
or
```
make
```
6. Start the debugging process in the IDE with `Go Remote` configuration.
```
Host: localhost
Port: 7000
```
7. Apply migrations:
```
make migrate
```
## API Endpoints
### All Orders with pagination
- Request URL: `http://localhost:8080/api/orders?start=0&end=1&sort_column=id&sort_type=asc`
- Method: `GET`
- Path: `/orders`
- Headers: `Accept:application/json, Content-Type:application/json`
- Parameters: `start, end, sort_column, sort_type`
- Status Code: `200`
- Response:
```json
{
"data": [
{
"id": 10000001,
"agency_name": "ОАО ITНефтьРыбОпт",
"status": "waiting",
"is_confirmed": false,
"is_checked": false,
"rental_date": "31-12-2023",
"user_name": "Валерия Фёдоровна Вишнякова",
"transport_count": 3,
"guest_count": 3,
"admin_note": null
}
]
}
```
### Create Order
- Request URL: `http://localhost:8080/api/orders`
- Method: `POST`
- Path: `/orders`
- Headers: `Accept:application/json, Content-Type:application/json`
- Parameters: `agency_name, rental_date, guest_count, transport_count, user_name, email, phone`
- Status Code: `200`
- Response:
```json
{
"data": {
"id": 10000011,
"agency_name": "Test Agency Name",
"status": "waiting",
"is_confirmed": false,
"is_checked": false,
"rental_date": "01-02-2024",
"user_name": "Test User Name",
"transport_count": 1,
"guest_count": 1,
"admin_note": "",
"note": "",
"email": "test@test.ru",
"phone": "71437854547",
"confirmed_at": null,
"created_at": "31-01-2024 22:11:14",
"updated_at": "31-01-2024 22:11:14"
}
}
```
### Order Details
- Request URL: `http://localhost:8080/api/orders/10000011`
- Method: `GET`
- Path: `/orders/{id}`
- Headers: `Accept:application/json, Content-Type:application/json`
- Status Code: `200`
- Response:
```json
{
"data": {
"id": 10000011,
"agency_name": "Test Agency Name",
"status": "waiting",
"is_confirmed": false,
"is_checked": false,
"rental_date": "01-02-2024",
"user_name": "Test User Name",
"transport_count": 1,
"guest_count": 1,
"admin_note": "",
"note": "",
"email": "test@test.ru",
"phone": "71437854547",
"confirmed_at": null,
"created_at": "31-01-2024 22:11:15",
"updated_at": "31-01-2024 22:11:15"
}
}
```
### Update Order
- Request URL: `http://localhost:8080/api/orders/10000011`
- Method: `PUT`
- Path: `/orders/{id}`
- Headers: `Accept:application/json, Content-Type:application/json`
- Parameters: `guest_count, transport_count, user_name, email, phone`
- Status Code: `200`
- Response:
```json
{
"data": {
"id": 10000011,
"agency_name": "Test Agency Name",
"status": "waiting",
"is_confirmed": false,
"is_checked": false,
"rental_date": "01-02-2024",
"user_name": "Test7",
"transport_count": 7,
"guest_count": 7,
"admin_note": "qq",
"note": "ww",
"email": "777@777.test",
"phone": "71111111111",
"confirmed_at": null,
"created_at": "31-01-2024 22:11:15",
"updated_at": "31-01-2024 22:17:47"
}
}
```
### Delete Order
- Request URL: `http://localhost:8080/api/orders/10000011`
- Method: `DELETE`
- Path: `/orders/{id}`
- Headers: `Accept:application/json, Content-Type:application/json`
- Status Code: `200`
- Response:
```json
{
"data": {
"id": 10000011,
"agency_name": "Test Agency Name",
"status": "waiting",
"is_confirmed": false,
"is_checked": false,
"rental_date": "01-02-2024",
"user_name": "Test7",
"transport_count": 7,
"guest_count": 7,
"admin_note": "qq",
"note": "ww",
"email": "777@777.test",
"phone": "71111111111",
"confirmed_at": null,
"created_at": "31-01-2024 22:11:15",
"updated_at": "31-01-2024 22:17:47"
}
}
```
没有合适的资源?快使用搜索试试~ 我知道了~
Go,Clean Architecture,SOLID,Golang 1.21
共80个文件
go:65个
gitignore:3个
example:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 115 浏览量
2024-02-02
10:55:57
上传
评论
收藏 70KB ZIP 举报
温馨提示
Go,Clean Architecture,SOLID,Golang 1.21,Gin Web Framework,Delve调试模式,GORM,Goose,Logrus,Viper,依赖注入,RESTful API,PostgreSQL 16,CRUD,DTO,MVC,Docker Compose,SQL,设计模式.zip
资源推荐
资源详情
资源评论
收起资源包目录
Go,Clean Architecture,SOLID,Golang 1.21,Gin Web Framework,Delve调试模式,GORM,Goose,Logrus,Viper,依赖注入,RESTful API,PostgreSQL 16,CRUD,DTO,MVC,Docker Compose,SQL,设计模式.zip (80个子文件)
go-code-examples-main
tools
goose
pkg
cfg
cfg.go 838B
go.mod 3KB
go.sum 55KB
.env.example 180B
Makefile 716B
readme.md 5KB
docker
entrypoint.sh 145B
Dockerfile 477B
Dockerfile.example 528B
cmd
tools
goose
main.go 9KB
http
main.go 117B
console
.keep 0B
docker-compose.yml 940B
internal
app
presenters
order_presenter.go 537B
error_presenter.go 933B
order_index_presenter.go 663B
helpers
config.go 700B
gorm_logger.go 2KB
dependencies_container.go 511B
http
resources
error_resource.go 253B
order_resource.go 2KB
order_index_resource.go 1KB
controllers
api
order_destroy_controller_contract.go 293B
order_index_controller.go 884B
order_index_controller_contract.go 470B
order_update_controller_contract.go 577B
order_update_controller.go 1KB
order_show_controller_contract.go 287B
order_store_controller_contract.go 606B
order_show_controller.go 982B
order_destroy_controller.go 1022B
order_store_controller.go 1017B
requests
order_index_request.go 900B
order_update_request.go 1KB
order_store_request.go 2KB
providers
database_provider.go 2KB
route_provider.go 1KB
container_provider.go 442B
logger_provider.go 2KB
config_provider.go 986B
bindings
use_case_provider.go 1KB
repository_provider.go 1KB
controller_provider.go 1KB
presenter_provider.go 533B
dto
pagination_dto.go 662B
models
agency.go 400B
order.go 2KB
types
order_status.go 485B
repositories
order_update_repository.go 833B
order_index_repository.go 869B
order_show_repository.go 594B
order_store_repository.go 1KB
order_index_repository_contract.go 153B
order_store_repository_contract.go 345B
order_destroy_repository.go 421B
order_update_repository_contract.go 281B
use_cases
order_show_use_case_contract.go 174B
order_index_use_case.go 738B
order_destroy_use_case.go 796B
order_store_use_case.go 496B
order_store_use_case_contract.go 525B
order_show_use_case.go 439B
order_index_use_case_contract.go 515B
order_update_use_case.go 832B
order_update_use_case_contract.go 552B
order_destroy_use_case_contract.go 260B
bootstrap
app.go 664B
database
migrations
20231213013352_create_agencies_table.go 575B
20231229201215_create_orders_table.go 800B
connection.go 726B
routes
api.go 596B
web.go 233B
config
http.go 194B
database.go 550B
app.go 153B
storage
docker
.gitignore 14B
logs
.gitignore 14B
pkg
.keep 0B
.gitignore 11B
.dockerignore 89B
共 80 条
- 1
资源评论
N201871643
- 粉丝: 1387
- 资源: 2713
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- [面板构架]Matlab设计-图像去雾基于Matlab设计-(多方法对比,PSNR,信息熵,GUI界面).zip
- springboot项目智能物流管理系统.zip
- [面板构架]Matlab设计-图像去雾系统(彩色,灰色均可处理,多方法对比,GUI框架).zip
- [面板构架]Matlab设计-图像去雾(多方法,GUI界面).zip
- [面板构架]Matlab设计-雾霾车牌识别GUI设计.zip
- [面板构架]Matlab设计-香烟汉字识别(模板匹配,多过程图,GUI界面).zip
- [面板构架]Matlab设计-危险区域预警(详细解析,GUI).zip
- [面板构架]Matlab设计-芯片字符识别(多过程图,模板匹配).zip
- [面板构架]Matlab设计-信号与系统,数字信号设计(含有GUI).zip
- springboot项目植物健康系统.zip
- springboot项目知识管理系统.zip
- Keil5集成开发环境在嵌入式系统中的应用与详细部署流程详解
- [面板构架]Matlab设计-印刷品缺陷检测(GUI界面,缺陷定位和计数).zip
- [面板构架]Matlab设计-指纹识别(GUI框架).zip
- springboot项目中小企业设备管理系统设计与实现.zip
- springboot项目中小型医院网站.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功