This repository contains a Go (Golang) project for building a RESTful API. It demonstrates the basic structure and components needed to create a RESTful API using Golang, including setting up a database, creating routes, middleware and implementing Unit Test.
To get started with this project, follow these steps:
-
Clone the repository:
git clone https://github.com/nugrohoarr/belajar-golang-restfulapi.git
-
Navigate to the project directory:
cd belajar-golang-restfulapi
-
Install the dependencies:
go mod tidy
-
Set up the database:
Create a MySQL database named
db_golang_test
and ensure it is running onlocalhost:3306
. You can modify the database connection settings intest/setup_test.go
if needed. -
Run the application:
go run main.go
To use the API, you can send HTTP requests to the endpoints defined in the project. You can use tools like curl
, Postman
, or any HTTP client of your choice to interact with the API.
The project structure is organized as follows: