Quick Start Guide

This guide provides the fastest way to get the go-clean-arch application up and running and make your first API call. It assumes you have already installed the prerequisites listed in the Installation guide (Go, Docker, Make, Git).

1. Clone the Repository

Open your terminal and clone the project to your local machine.

git clone https://github.com/bxcodec/go-clean-arch.git
cd go-clean-arch

2. Create the Environment File

The application requires a .env file for configuration. You can create it by copying the provided example file.

cp example.env .env

The default settings are pre-configured to work with the Docker setup, so no modifications are needed.

3. Launch the Application

Use the make command to start the application and its database via Docker Compose. This command also enables hot-reloading for development.

make up

Wait for the command to finish. You will see logs indicating that the database is healthy and the Go application server has started on port 9090.

4. Make Your First API Call

With the server running, you can now interact with the API. Open a new terminal window and use curl to fetch a list of articles.

curl localhost:9090/articles

Expected Response

You should see a JSON array of article objects populated from the initial article.sql data:

[
    {
        "id": 1,
        "title": "Makan Ayam",
        "content": "<p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born...",
        "author": {
            "id": 1,
            "name": "Iman Tumorang",
            "created_at": "2017-05-18T13:50:19Z",
            "updated_at": "2017-05-18T13:50:19Z"
        },
        "updated_at": "2017-05-18T13:50:19Z",
        "created_at": "2017-05-18T13:50:19Z"
    },
    {
        "id": 2,
        "title": "Makan Ikan",
        "content": "<h1>Odio Mollis Turpis Dictumst</h1>...",
        "author": {
            "id": 1,
            "name": "Iman Tumorang",
            "created_at": "2017-05-18T13:50:19Z",
            "updated_at": "2017-05-18T13:50:19Z"
        },
        "updated_at": "2017-05-18T13:50:19Z",
        "created_at": "2017-05-18T13:50:19Z"
    }
]

What's Next?

You have successfully run the application and retrieved data from its API. From here, you can:

  • Explore the different API endpoints in the API Reference.
  • Dive deeper into the project's structure in the Architecture section.
  • Learn how to build and deploy the application in the Deployment guide.