7
3
Fork
You've already forked env
0

Nested structs handling #1

Merged
elisiei merged 15 commits from nested-structs into main 2026年03月28日 15:29:47 +01:00

Solves the nested struct handling. Struct fields can be tagged with `env:"nested"` in order to be loaded in the same function call as their parent, otherwise they will be ignored. Using any other tag from this package will result in an error.

Solves the nested struct handling. Struct fields can be tagged with \`env:"nested"\` in order to be loaded in the same function call as their parent, otherwise they will be ignored. Using any other tag from this package will result in an error.
El-Power changed title from (削除) Nested structs handling (削除ここまで) to Nested struct handling 2026年03月25日 16:11:39 +01:00
El-Power changed title from (削除) Nested struct handling (削除ここまで) to Nested structs handling 2026年03月25日 16:11:52 +01:00

thanks, i've wanted to add this feature but didn't had the motivation. altough the struct tag should be actually useful for the nested syntax.

example of code:

typeConfigstruct{ServerServerConfig`env:"SERVER_"`// this will be the prefix of all env vars for ServerConfigDebugbool`env:"DEBUG,default=false"`}typeServerConfigstruct{Portint`env:"PORT"`// so this will parse as `SERVER_PORT`}
thanks, i've wanted to add this feature but didn't had the motivation. altough the struct tag should be actually useful for the nested syntax. example of code: ```go type Config struct { Server ServerConfig `env:"SERVER_"` // this will be the prefix of all env vars for ServerConfig Debug bool `env:"DEBUG,default=false"` } type ServerConfig struct { Port int `env:"PORT"` // so this will parse as `SERVER_PORT` } ```
Author
Member
Copy link

Done 👍

Done 👍

lgtm

lgtm
Sign in to join this conversation.
No reviewers
Labels
Clear labels
Compat/Breaking
Breaking change that won't be backward compatible
Kind/Bug
Something is not working
Kind/Documentation
Documentation changes
Kind/Enhancement
Improve existing functionality
Kind/Feature
New functionality
Kind/Security
This is security issue
Kind/Testing
Issue or pull request related to testing
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ungo/env!1
Reference in a new issue
ungo/env
No description provided.
Delete branch "nested-structs"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?