Reljod's Repository
API Backend for my own personal Portfolio written in Golang.
Sections
Rest API
In local, you can find the Swagger examples at http://localhost:8888/swagger/index.html
Endpoints as of now:
- Personal Info Endpoints.
- Heap Endpoints.
Data Structures and Algorithms
The code can be found under the folder ./app/algo/...
Design Patterns
The code can be found under the folder ./app/designpattern/...
- Design Patterns implemented so far:
Best Practices
Local Development
- Git Clone the repo.
- Install Go from the official Golang install link here
- Under the root folder, run
go mod tidy
- Run
- To run the Rest API, run the
main.go
under the root folder. Then access the swagger under http://localhost:8888.
Example:
go run main.go
- To execute the algorithms, design pattern examples, run the code under exec/...
Example:
go run exec/<folder>/<filename.go>
- (Important) Configure Environmental Variables to change the api behavior. The environmental behaviors can be found in
config.env
. As of now, PORT and logging level can be set by config.env.
- (Important) Set DATABASE_URL to MongoDB URL as currently, the application uses MongoDB as its NoSQL Database.
Testing
- Simply run
go test -v ./...
to test all available tests in the Repo.
Benchmark
- Simply run
go test -v -benchmem -bench "." "./..."
to test all available benchmark tests in the Repo.
VSCode Guide
If we're using VSSCode in our development, follow the instructions below to easily execute Go script or run the local server.
- At the top section, click
Run
then Add configurations
.
- Click the
Add configuration
. This should add the launch.json
file under .vscode
folder.
- Edit the
launch.json file
and use the configuration below:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Connect to server",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 8888,
"host": "127.0.0.1",
},
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {
"DATABASE_URL": "<database_url>" // ask this to the owner.
}
}
]
}
- To run the script, just open the file that you want to run and click
ctrl + F5
or Run without Debugging.
- To know more, please message me at my LinkedIn Account.
- Or email me at
oretareljod@gmail.com