caarlos0 / caarlos0/env

support for suffix

Open
#394 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
6.3k
Forks
284
Avg merge
1d 17h
Merged PRs (30d)
1

Description

Hi!, thank you for your amazing work.

I have a use case where I need some variables to have the country iso as a suffix. For example:

```
THIRDPARTY_API_KEY_US
THIRDPARTY_API_SECRET_US
THIRDPARTY_API_KEY_MX
THIRDPARTY_API_SECRET_MX
```

The prefix option would be nice for cutting `THIRDPARTY` so it would be nice to have a suffix option for the country iso, so that I can write the struct just like

```go
type ApiCredentials struct {
ApiKey string "env:API_KEY"
ApiSecret string "env:API_SECRET"
```

and then in the parsing stage, use prefix and suffix.

I think it would be a good addition to the library. Or is there a nice way to do this with the current tools?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the environment-variable parsing stage and the existing prefix option in the Go library. Check how struct tags such as env:API_KEY are interpreted, then add suffix handling for names like THIRDPARTY_API_KEY_US and verify that the requested country-specific variables populate the struct fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.