- Back-end
- Clean Architecture
- CRUD
- Debugging Mode
- Delve
- Dependency Injection
- Design Patterns
- Docker Compose
- Dockerfile with multi-stage builds
- DTO
- Gin Web Framework
- Golang 1.21
- Goose
- GORM
- Linux
- Logrus
- Makefile
- MVC
- PostgreSQL 16
- RESTful API
- SOLID
- SQL
- Viper
- Clone this repository:
git clone git@github.com:d-alejandro/go-code-examples.git
- Go to
go-code-examples
directory:
cd go-code-examples
- Create a new .env file:
cp .env.example .env
-
Download and install
Go
SDK1.21.6
. -
Build and run the application:
make run
or
make
- Start the debugging process in the IDE with
Go Remote
configuration.
Host: localhost
Port: 7000
- Apply migrations:
make migrate
- 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:
{
"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
}
]
}
- 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:
{
"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"
}
}
- 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:
{
"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"
}
}
- 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:
{
"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"
}
}
- 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:
{
"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"
}
}