Giter Site home page Giter Site logo

belajar-go's Introduction

Belajar Go Project

This project is a Go-based web application utilizing Gin Gonic for the web framework, GORM for ORM, and PostgreSQL as the database. It includes features such as user and role management with JWT-based authentication and more.

Project Structure

belajar-go/
│
├── cmd/
│     └── main.go
│
├── configs/
│     └── dbConfig.go
│
├── internal/
│     ├── delivery/
│     │     ├── handlers/
│     │     │     └── bookHandler/
│     │     │               └── bookHandler.go
│     │     │
│     │     ├── data/
│     │     │     ├── request/
│     │     │     │     └── bookReq/
│     │     │     │          └── bookRequest.go
│     │     │     │
│     │     │     └── response/
│     │     │          ├── bookRes
│     │     │          │     └── bookResponse.go
│     │     │          └── response.go
│     │     │     
│     │     └── router/ 
│     │           ├── bookRouter/
│     │           │          └── bookRouter.go
│     │           │
│     │           └── router.go
│     │
│     ├── domain/
│     │     ├── models/
│     │     │     └── books.go
│     │     │
│     │     ├── repositories/
│     │     │     ├── bookRepo/
│     │     │     │      └── bookRepo.go
│     │     │     │
│     │     │     └── repoInterface/
│     │     │            └── bookRepoInterface.go
│     │     │
│     │     └── services/
│     │           ├── bookService/
│     │           │      └── bookService.go
│     │           │
│     │           └── serviceInterface/
│     │                  └── bookServiceInterface.go
│     │         
│     └── infrastructure/
│           └── database/
│                  ├── database.go
│                  └── migrations.go
│
├── pkg/
│     ├── utils/
│     │     └── base.go
│     │
│     └── helpers/
│           └── errorPanic.go
│
├── .env.example
├── .gitignore
├── go.mod
└── go.sum

Getting Started

Prerequisites

  • Go 1.22+
  • PostgreSQL
  • CompileDaemon for live reloading during development

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/belajar-go.git
    cd belajar-go
  2. Copy the example environment variables file and configure it:

    cp .env.example .env
  3. Install the dependencies:

    go mod download

Configuration

Update the .env file with your database credentials and other configurations.

Database Setup

  1. Create the database:
    createdb belajar_go

Running the Application

You can use CompileDaemon to automatically rebuild and restart the application when you make changes to the source code.

  1. Install CompileDaemon:

    go install github.com/githubnemo/CompileDaemon@latest
  2. Start the application:

    CompileDaemon --build="go build cmd/main.go" --command=./main

API Documentation

Endpoints

Books
  • GET /books - Get all books
  • POST /books - Create a new book
  • GET /books/:id - Get a book by ID
  • PUT /books/:id - Update a book by ID
  • DELETE /books/:id - Delete a book by ID

Project Structure Explanation

  • cmd/: Entry point of the application.
  • configs/: Configuration files.
  • internal/: Internal application code.
    • delivery/: Contains the HTTP handlers and routers.
    • domain/: Contains the business logic and models.
    • infrastructure/: Contains the database setup and migrations.
  • pkg/: Utility packages and helpers.
  • .env.example: Example environment variables file.
  • go.mod: Go module file.
  • go.sum: Go module dependencies file.

belajar-go's People

Contributors

awahids avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.