go-api

module
v0.0.0-...-ebe49b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: MIT

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

  1. Clone the repository:
git clone https://github.com/johnsilver94/go-api.git
  1. Navigate to the project directory:
cd go-api
  1. 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

  1. Copy the example configuration file and update it with your settings:
cp .env.example .env
  1. Edit config.json to match your database and other configuration settings.

Running the Application

  1. Start the application:
make run
  1. The API will be available at http://localhost:{PORT}.

Database Migrations

  1. Create a new migration:
make migration <migration_name>
  1. Apply all migrations:
make migration-up
  1. Rollback the last migration:
make migration-down

Testing

Run the tests using:

go test ./...

Directories

Path Synopsis
cmd
api
services

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL