Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
github.com/softwarespot/public-holidays
This project showcases my proficiency in Go by creating a clear and readable public holidays API. The primary focus is on writing clean, maintainable code that effectively demonstrates the logic behind retrieving public holidays for a country's ISO 3166-1 alpha-2 code.
This endpoint retrieves a list of public holidays for a specified country and
year. By replacing {country}
with the two-letter ISO 3166-1 alpha-2 code of
the desired country and {year}
with the target year, users can access detailed
information about each holiday, including dates, local names and English names.
This API is useful for applications that need to display or utilize holiday data
for various purposes, such as scheduling or planning.
This API is available at https://public-holidays.onrender.com.
IMPORTANT The instance might be down due to inactivity, therefore, wait about 50s for the instance to be started again.
curl -s "https://public-holidays.onrender.com/holidays/v1/FI/2024" | jq
# or locally
curl -s "http://localhost:10000/holidays/v1/FI/2024" | jq
The response will be in JSON format and includes an array of holiday objects with the following details:
[
{
"date": "2024-01-01",
"name": "Uudenvuodenpäivä",
"englishName": "New Year's Day"
},
{
"date": "2024-01-06",
"name": "Loppiainen",
"englishName": "Epiphany"
},
...
]
Here is a list of the supported countries.
Country | ISO 3166-1 alpha-2 | Wikipedia Link |
---|---|---|
🇩🇰 Denmark | DK | Public Holidays in Denmark |
🇫🇮 Finland | FI | Public Holidays in Finland |
🇮🇸 Iceland | IS | Public Holidays in Iceland |
🇳🇴 Norway | NO | Public Holidays in Norway |
🇸🇪 Sweden | SE | Public Holidays in Sweden |
Makefile
provided)IMPORTANT: No 3rd party dependencies are used.
I could easily use Cobra (and usually I do, because it allows me to write powerful CLIs), but I felt it was too much for such a tiny project. I only ever use dependencies when it's say an adapter for an external service e.g. Redis, MySQL or Prometheus.
.env
(used when developing locally) and .env.production
(used when deploying to production)cp .env.example .env
cp .env.example .env.production
go run .
or when using make
make
./bin/public-holidays
Display the version of the application and exit.
# As text
./bin/public-holidays --version
# As JSON
./bin/public-holidays --json --version
Display the help text and exit.
./bin/public-holidays --help
public-holidays
.docker build -t public-holidays .
# Port number should the same as defined in ".env.production"
docker run -p "10000:10000" --rm public-holidays
Display the version of the application and exit.
# As text
docker run --rm public-holidays --version
# As JSON
docker run --rm public-holidays --json --version
Display the help text and exit.
docker run --rm public-holidays --help
Tests are written as Table-Driven Tests.
go test -cover -v ./...
or when using make
make test
Docker
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:latest golangci-lint run -v --tests=false --disable-all -E durationcheck,errorlint,exhaustive,gocritic,gosimple,ineffassign,misspell,predeclared,revive,staticcheck,unparam,unused,whitespace --max-issues-per-linter=10000 --max-same-issues=10000
Local
golangci-lint run --tests=false --disable-all -E durationcheck,errorlint,exhaustive,gocritic,gosimple,ineffassign,misspell,predeclared,revive,staticcheck,unparam,unused,whitespace --max-issues-per-linter=10000 --max-same-issues=10000
This section documents any additional information which might be deemed important for the reviewer.
slices
pkg being available, I have opted not
to use it, and instead went for how I've been writing Go code before the
slices
pkg existed. Although for production code, I have started to use it
where applicable.The code has been licensed under the MIT license.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.