This repository was created from the repository at https://github.com/SchwarzIT/go-code-review to make corrections and improvements
Configure the application using environment variables with support for a .env
file and default values.
API_PORT
- Explanation: API port
- required
API_ENV
- Explanation: Type of environment "development"|"production"
- Default:
development
API_TIME_ALIVE
- Explanation: Time max to server keep alive
- Format: Specify the duration using units like s (seconds), m (minutes), h (hours), d (days), w (weeks), or y (years). Example: 10d 10w 1y.
- Without value: API will run without duration
API_SHUTDOWN_TIMEOUT
- Explanation: Time max to server wait the request finishing when is shutdown
- Format: Specify the duration using units like s (seconds), m (minutes), h (hours), d (days), w (weeks), or y (years). Example: 10d 10w 1y.
- Default:
30s
API_ALLOW_ORIGINS
- Explanation: Allow origins by CORS. Is valid only is production environment
- Format: Specify the hostname divide by split
https://example.com,https://api.example.com
- Default: Allow all origins
Create a .env
file in the project root to set default values:
API_PORT=9090
API_ENV=production
API_TIME_ALIVE=1y
API_SHUTDOWN_TIMEOUT=60s`
API_ALLOW_ORIGINS=https://example.com,https://api.example.com
- System Environment Variables override
.env
values. .env
File provides defaults.- Struct Defaults apply if neither is set.
Example:
.env
hasAPI_PORT=9090
- System sets
API_PORT=7070
- Effective
API_PORT
:7070
The releases folder is used to store version-specific metadata for project updates, such as features, improvements, and bug fixes. Each release file is structured using the standard template located at ./templates/release.toml.
Workflow Automation The repository includes a CI/CD pipeline to validate and manage release files:
- Validation:
When a pull request is opened or updated, the pipeline validates the release.toml file using the script
scripts/validate_release.go
to ensure it follows the required structure. - Merge Handling:
When a pull request is merged, the pipeline automatically moves the validated
release.toml
file into the releases folder, renaming it with a timestamp for unique identification.
- Use the provided template at
./templates/release.toml
to create a new release file. - Ensure the file is added to your pull request and follows the required structure.
- Upon merging, the CI/CD pipeline will handle validation and placement in the releases folder.