This is the backend of NYCU SDC Clustron Project.
We aim to create a service to visuallize the LDAP access managing, Slurm operation, and resource usage on remote computer cluster.
Follow the official installation guide. Choose version 1.24 if you would like to specify the Go version.
Open your terminal and navigate to the directory that you wish to put this project.
And then execute the following command:
git clone https://github.com/NYCU-SDC/clustron-backend.git
cd clustron-backend
git fetch
make prepare
Be sure you have make installed. You can check by:
make -v
If the result is something like make command not found, install make before running the above command.
We use sqlc for database queries generation and mockery for mocking. Please make sure your mockery version is v3.7.0, otherwise the generated mock code will not work with our codebase.
brew install sqlc
brew install mockery
brew upgrade mockery
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
go install github.com/vektra/mockery/v3@v3.7.0
You can also find more OS-spacific installing methods from the documentation.
You can simply start the backend service via command:
make run
To build the backend code into binary, run:
make build
The binary file will be ./bin/backend.
We recommand you enable the pre-push hook if wish to commit to this repository. This will run checks before the code is pushed to the remote.
The pre-push hook is run via lefthook.
brew install lefthook
go install github.com/evilmartians/lefthook@latest
You can also find more OS-spacific installing methods from the documentation.
After installed lefthook, update git hook to use lefthook:
# run at project root
left hook install
Then you are good to go!
The pre-push checks will be envoked when you do git push.
If the checks didn't pass, the push will be blocked.
To temporary by pass the pre-push check and push:
git push origin --no-verify
To disable pre-push action until re-open it:
left hook uninstall
This project uses go-callvis to visualize Go code execution and function calls.
go install github.com/ofabry/go-callvis@latestBy default, this command opens an interactive graph in your web browser (press Ctrl+C to stop the server).
-
Analyze Default Entry Point (
cmd/backend/main.go):make flow-chart
-
Analyze a Specific Module:
make flow-chart TARGET=./cmd/backend/main.go FOCUS=user
-
Export to Image (No Browser): Use
EXTRA_FLAGSto save the output directly as an SVG or PNG file.make flow-chart TARGET=./internal/user FOCUS=user EXTRA_FLAGS="-format svg -file user_flow"