Skip to content

achl1012/cvwo-assignment-backend

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CVWO Assignment Backend

Getting Started

Installing Go

Download and install Go by following the instructions here.

Running the app

  1. Fork this repo.

  2. Clone your forked repo.

  3. Open your terminal and navigate to the directory containing your cloned project.

  4. Install dependencies

    You can install necessary Go packages via:

    go mod tidy
  5. Set Up PostgreSQL Locally

    If you don't have PostgreSQL installed, download and install it from here.

    After installing, you can create a local PostgreSQL database and user as follows:

  • Start the PostgreSQL server
    Run the following command to start the PostgreSQL server (adjust the command based on your OS and PostgreSQL installation):

    pg_ctl -D /usr/local/var/postgres start  # Example for macOS
  • Access the PostgreSQL command line

    Enter the following command:

    psql postgres
  • Create a new database and user

    Run the following SQL commands to create a new database and user:

    CREATE DATABASE forumflow;
    CREATE USER yourusername WITH PASSWORD 'yourpassword';
    ALTER ROLE yourusername SET client_encoding TO 'utf8';
    ALTER ROLE yourusername SET default_transaction_isolation TO 'read committed';
    ALTER ROLE yourusername SET timezone TO 'UTC';
    GRANT ALL PRIVILEGES ON DATABASE forumflow TO yourusername;
  1. Configure .env file

    Create a .env file in the root of the backend folder if it doesn't already exist.

    Set the DATABASE_URL variable to your local database credentials:

    DATABASE_URL=postgres://yourusername:yourpassword@localhost:5432/forumflow?sslmode=disable

    Note: Replace yourusername and yourpassword with the credentials you used to set up the database. If you're using a different host or port, make sure to adjust the URL accordingly.

  2. Run the backend

    Start the Go backend server:

    go run cmd/server/main.go

    Your backend should now be running at http://localhost:10000

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%