-
Visit the Go official download page.
-
Download the Go installer package suitable for your operating system.
-
Follow the Go installation guide to complete the installation.
-
After installation, open a terminal and run the following command to verify the installation:
go version
If the installation is successful, you will see the Go version information.
-
Visit the Node.js official website.
-
Download and install the LTS (Long Term Support) version suitable for your operating system.
-
After installation, open a terminal and run the following commands to verify the installation:
node --version npm --version
-
Install Yarn:
npm install -g yarn
-
Verify Yarn installation:
yarn --version
-
Determine your workspace: Choose a directory as your Go workspace, e.g.,
~/go
. -
Set
GOPATH
: Add the following to your shell configuration file (e.g.,.bashrc
or.zshrc
):export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin
-
Apply changes: Run one of the following commands to ensure the configuration file updates take effect:
source ~/.bashrc # or source ~/.zshrc
-
Verify settings: Run the following command to verify that
GOPATH
is set correctly:go env GOPATH
The output should be your workspace directory, e.g.,
/home/username/go
.
-
Install direnv: Follow the instructions in the direnv official documentation to install.
-
Configure direnv: Add the following line to your shell configuration file (e.g.,
.bashrc
,.zshrc
, etc.):eval "$(direnv hook bash)" # if using bash # or eval "$(direnv hook zsh)" # if using zsh
Reload your shell configuration file or restart your terminal.
-
Create .envrc file: In the project root directory, run:
cp .envrc.example .envrc
-
Edit .envrc file: Edit the
.envrc
file according to your needs, setting necessary environment variables. For example:export CSGHUB_PORTAL_S3_ACCESS_KEY_ID=xxx export CSGHUB_PORTAL_S3_ACCESS_KEY_SECRET=yyy # Add other required environment variables
-
Allow direnv to load .envrc file: In the project root directory, run:
direnv allow .
To install necessary Go modules, run:
go mod tidy
Air is a tool that allows live reloading of Go applications. Install it using the following command:
go install github.com/cosmtrek/air@latest
Open the frontend
directory and use Yarn to install dependencies:
cd frontend
yarn install
-
Create database: Create a new database in your database management system. PostgreSQL is recommended, and you can use the following command:
CREATE DATABASE your_database_name;
Make sure to replace
your_database_name
with the actual database name you want to use. -
Update .envrc file: Ensure your
.envrc
file contains the correct database connection information. -
Initialize database: Run the following command to initialize the database:
go run cmd/csghub-portal/main.go migration init
-
Execute database migrations: Run the following command to execute database migrations:
go run cmd/csghub-portal/main.go migration migrate
To start both frontend and backend services simultaneously, run the following command:
make
If you only want to start the frontend service, run the following command:
make run-frontend
If you only want to start the Go service, run the following command:
make run-backend
-
Create .env file:
- In the project root directory, locate the
.env.example
file. - Copy
.env.example
and rename the copy to.env
. - Open the
.env
file and fill in all necessary environment variables according to your environment configuration.
cp .env.example .env
- In the project root directory, locate the
-
Edit .env file:
- Open the
.env
file with a text editor. - Fill in or modify each configuration item according to your development environment and requirements.
- Ensure all necessary environment variables are correctly set.
- Open the
-
In VS Code, open the "Run and Debug" view (usually the play button icon in the sidebar).
-
In the top dropdown menu, you can choose one of the following configurations:
- "portal": Start the main server
- "init": Initialize the database
- "migrate": Execute database migration
- "rollback": Rollback database migration
-
Compile the project:
make build
-
Run the compiled executable:
./csghub-portal start server
When both services are running, open your web browser and visit:
This will allow you to view and interact with the application.