-
Notifications
You must be signed in to change notification settings - Fork 50
2. Getting Started
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
-
Clone the repository:
git clone https://github.com/hngprojects/hng_boilerplate_golang_web.git cd hng_boilerplate_golang_web
-
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
-
Configure Environment Variables: Create an
app.env
file at the project root and populate it with values fromapp-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 Locally
-
Ensure PostgreSQL is Running: Make sure PostgreSQL is up and running.
-
Populate the
app.env
File: Ensure all necessary environment variables are set inapp.env
. -
Run the Application: From the project root, run:
go run main.go
The application will start and be accessible at http://localhost:8019
.
Upon successful startup, you should see logs indicating that the server is running: