This project is a simple application built using Go programming language that demonstrates file upload and download functionalities using Amazon S3. The project follows a clean code architecture, promoting modularity and maintainability.
The go-aws-s3-clean-arch project showcases how to upload and download files to/from Amazon S3 using a clean architecture approach. It emphasizes separation of concerns and modularity, making it easier to expand and maintain the application.
The project utilizes the following packages:
- AWS SDK: A comprehensive SDK for integrating Go applications with Amazon Web Services, providing functionalities for interacting with Amazon S3 and other AWS services.
- GIN: A web framework written in Go that combines high performance with an API similar to Martini.
- GORM with PostgreSQL: A powerful ORM library for Go that simplifies database operations.
- Wire: A code generation tool for dependency injection, making it easier to connect components.
- Viper: A configuration solution for Go applications, supporting various formats and 12-Factor app principles.
- swag with gin-swagger and swaggo files: Converts Go annotations to Swagger Documentation 2.0 for API documentation.
Please refer to the respective package documentation for more information on their usage and integration. Setup Instructions
To use and test the go-aws-s3-clean-arch project, follow these steps: Prerequisites
Ensure the following software is installed on your system:
Go (https://golang.org/doc/install)
PostgreSQL (https://www.postgresql.org/download/)
AWS account and S3 bucket (https://aws.amazon.com/s3/)
Clone the go-aws-s3-clean-arch repository to your local system:
git clone https://github.com/your-username/go-aws-s3-clean-arch.git
cd go-aws-s3-clean-arch
Install the required dependencies using either the provided Makefile command or Go's built-in module management:
# Using Makefile
make deps
# OR using Go
go mod tidy
Create a .env file in the project's root directory and set the following variables:
# Database
DB_HOST="your-database-host"
DB_NAME="your-database-name"
DB_USER="your-database-user"
DB_PASSWORD="your-database-password"
DB_PORT="your-database-port"
# AWS S3
AWS_ACCESS_KEY_ID="your-aws-access-key-id"
AWS_SECRET_ACCESS_KEY="your-aws-secret-access-key"
AWS_REGION="your-aws-region"
AWS_BUCKET_NAME="your-s3-bucket-name"
# Server
PORT="server-port"
Run the following command to generate the Wire injectors:
make wire
make run