module
Version:
v0.0.0-...-ebe49b8
Opens a new window with list of versions in this module.
Published: Nov 28, 2024
License: MIT
Opens a new window with license information.
README
¶
Go API Project
Introduction
This project is a RESTful API built with Go. It provides various endpoints to manage resources.
Prerequisites
- Go 1.16 or higher
- Git
- A running instance of a database (e.g., PostgreSQL, MySQL)
Installation
- Clone the repository:
git clone https://github.com/johnsilver94/go-api.git
- Navigate to the project directory:
cd go-api
- Install dependencies:
go mod tidy
Folder Structure
.editorconfig
: Configuration file for maintaining consistent coding styles.
.env
: Environment variables file.
.env.example
: Example environment variables file.
.gitignore
: Specifies files and directories to be ignored by Git.
.husky/
: Configuration for Husky, which manages Git hooks.
.vscode/
: Visual Studio Code workspace settings.
bin/
: Compiled binary files.
cmd/
: Entry points for the application.
api/
: Main API server entry point.
migrate/
: Database migration scripts.
configs/
: Configuration files.
db/
: Database connection and initialization.
http/
: HTTP request files for testing endpoints.
Makefile
: Makefile for build automation.
Configuration
- Copy the example configuration file and update it with your settings:
cp .env.example .env
- Edit
config.json
to match your database and other configuration settings.
Running the Application
- Start the application:
make run
- The API will be available at
http://localhost:{PORT}
.
Database Migrations
- Create a new migration:
make migration <migration_name>
- Apply all migrations:
make migration-up
- Rollback the last migration:
make migration-down
Testing
Run the tests using:
go test ./...
Directories
¶
|
|
|
|
|
|
|
|
|
|
services
|
|
|
|
|
|
|
|
|
|
|
|
Click to show internal directories.
Click to hide internal directories.