-
Notifications
You must be signed in to change notification settings - Fork 1
Comprehensive library improvements: generics, performance, API consistency, and documentation #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2d3d2bb
small fixes to code comments and error messages
rayjlinden fd045bc
small performance improvements suggested by claude
rayjlinden f95c1b4
various code design issues resolved as suggested by claude
rayjlinden 995e7db
moved to use go generics, much nicer implementation!
rayjlinden 759a9bb
improved the docuementation a bunch
rayjlinden 95e27b4
lint
rayjlinden 8762dca
missing space
rayjlinden cdf27fc
update version to build with in workflow
rayjlinden b960214
adjust when tag job runs
rayjlinden 4c18601
verbup
rayjlinden 1bd0db4
adjust tag logic
rayjlinden dc01619
moved tag.sh
rayjlinden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 0.4.5 | ||
| 0.4.6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // Package env provides utilities for working with environment variables and loading | ||
| // configuration from .env files. | ||
| // | ||
| // This package offers three main areas of functionality: | ||
| // | ||
| // 1. Simple environment variable access with type conversion | ||
| // 2. Struct-based configuration parsing using struct tags | ||
| // 3. Loading and parsing of .env files | ||
| // | ||
| // # Basic Usage | ||
| // | ||
| // Get environment variables with automatic type conversion: | ||
| // | ||
| // port, err := env.GetInt("PORT") | ||
| // if err != nil { | ||
| // port = env.GetOrInt("PORT", 8080) // with default | ||
| // } | ||
| // | ||
| // // Or panic if missing/invalid | ||
| // dbHost := env.MustGet("DATABASE_HOST") | ||
| // | ||
| // # Struct-based Configuration | ||
| // | ||
| // Parse environment variables into structs using tags: | ||
| // | ||
| // type Config struct { | ||
| // Host string `env:"HOST" envDefault:"localhost"` | ||
| // Port int `env:"PORT" envDefault:"8080"` | ||
| // Debug bool `env:"DEBUG"` | ||
| // } | ||
| // | ||
| // var cfg Config | ||
| // if err := env.Parse(&cfg); err != nil { | ||
| // log.Fatal(err) | ||
| // } | ||
| // | ||
| // # File Loading | ||
| // | ||
| // Load environment variables from .env files: | ||
| // | ||
| // // Load from .env file | ||
| // err := env.Load() | ||
| // if err != nil { | ||
| // log.Fatal(err) | ||
| // } | ||
| // | ||
| // // Load from specific files | ||
| // err = env.Load("config.env", "local.env") | ||
| // | ||
| // # Supported Types | ||
| // | ||
| // The package supports automatic conversion for: | ||
| // - bool, int, uint, int64, uint64, float32, float64 | ||
| // - time.Duration (using time.ParseDuration format) | ||
| // - *url.URL (using url.ParseRequestURI) | ||
| // - []string and other slice types (comma-separated by default) | ||
| // - Any type implementing encoding.TextUnmarshaler | ||
| // | ||
| // # Struct Tags | ||
| // | ||
| // When using Parse functions, the following struct tags are supported: | ||
| // - env:"VAR_NAME" - specifies the environment variable name | ||
| // - envDefault:"value" - provides a default value if the variable is not set | ||
| // - required:"true" - makes the field required (parsing fails if missing) | ||
| // - envSeparator:";" - custom separator for slice types (default is comma) | ||
| // - envExpand:"true" - enables variable expansion using os.ExpandEnv | ||
| // | ||
| // # Error Handling | ||
| // | ||
| // Functions come in three variants for different error handling approaches: | ||
| // - Get*() functions return (value, error) | ||
| // - GetOr*() functions return value with a fallback default | ||
| // - MustGet*() functions panic if the variable is missing or invalid | ||
| package env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.