Skip to content
Osinachi Chukwujama edited this page Jul 22, 2024 · 9 revisions

Getting Started

Prerequisites

Before you start, ensure you have the following:

  • Go 1.19 or later: Install Go
  • PostgreSQL 14 or later

You can use the install_postgresql_and_go.sh script in the scripts directory to install Go and PostgreSQL. Run it like so:

cd scripts
sudo bash install_postgresql_and_go.sh

Setup

  1. Clone the repository:

    git clone https://github.com/hngprojects/hng_boilerplate_golang_web.git
    cd hng_boilerplate_golang_web
  2. Setup PostgreSQL: Ensure PostgreSQL is up and running. Use the setup_postgres.sh script in the scripts directory to set up the databases and users of the application. Use the snippet below to achieve this:

cd scripts
sudo bash setup_postgres.sh
  1. Configure Environment Variables: Create an app.env file at the project root and populate it with values from app-sample.env. Afterwards, modify the database details to match the snippet below:

    DB_HOST=localhost
    DB_PORT=5432
    DB_USER=developmwnt_user
    DB_PASSWORD=password
    DB_NAME=development_db

Running_the_Application

Running Locally

Steps to Start the Application

  1. Ensure PostgreSQL is Running: Make sure PostgreSQL is up and running.

  2. Populate the app.env File: Ensure all necessary environment variables are set in app.env.

  3. Run the Application: From the project root, run:

    go run main.go

The application will start and be accessible at http://localhost:8019.

Example Output

Upon successful startup, you should see logs indicating that the server is running: