This project aims to create a simple REST API using the Go programming language (Golang). It leverages various Go libraries to handle routing (Gorilla Mux), logging (httpsnoop), CORS middleware (Gorilla handlers), and database interactions (pgx, gorm). The API connects to a PostgreSQL database and uses GORM (Go Object-Relational Mapper) for database operations..
Create an .env file in the root of the project and define your database user and password in it and place the file in docker-compose.yml For example:
# .env
DATABASE_USER=use
DATABASE_PASSWORD=password
# use in docker-compose.yml
PGADMIN_DEFAULT_EMAIL: ${DATABASE_USER}
PGADMIN_DEFAULT_PASSWORD: ${DATABASE_PASSWORD}
To use it, you need to clone the repository, install the dependencies and run the project.
# Open terminal/cmd and then Clone this repository
$ git clone https://github.com/JuanCampbsi/api_go_rest.git
# Access project folder in terminal/cmd
$ cd api_go_rest
# Install the dependencies
$ go mod tidy
# Run the application in development mode
$ go run main.go
# In order to create a container for this application, you'll need to run Docker command.
#Please ensure that Docker is already installed on your machine before proceeding.
#If you don't have Docker installed, you can download it from the
#[official website](https://www.docker.com/products/docker-desktop).
$ docker compose up
- Golang - version 1.20
- Gorilla Mux - version 1.8.0
- Gorilla handlers - version 1.5.1
- GORM - version 1.25.1
- PostgreSQL - version 10.22
👨💻 Author 💻
Developed by Juan Campos