Skip to content

Commit

Permalink
update readme and package header
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly committed Nov 7, 2023
1 parent 6f7d3cb commit d7be23c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ Using
kv, errs := struct2env.StructToEnvVars(foo)
txt := struct2env.ToShellWithPrefix("TST_", kv)
```

Type conversions:

- Most primitive type to their string representation, single quote (') escaped.
- []byte are encoded as base64
- time.Time are formatted as RFC3339
- time.Duration are in (floating point) seconds.
20 changes: 9 additions & 11 deletions env.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// Package env provides conversion from structure to and from environment variables.
//
// It supports converting struct fields to environment variables using field tags,
// handling different data types, and transforming strings between different case
// conventions, which is useful for generating or parsing environment variables,
// JSON tags, or command line flags.
// Supports converting struct fields to environment variables using field tags,
// handling most data types. Provides functions to serialize structs into slices
// of key-value pairs where the keys are derived from struct field names transformed
// to upper snake case by default, or specified explicitly via struct field tags.
//
// The package also defines several case conversion functions that aid in manipulating
// strings to fit conventional casing for various programming and configuration contexts.
// Additionally, it provides functions to serialize structs into slices of key-value pairs
// where the keys are derived from struct field names transformed to upper snake case by default,
// or specified explicitly via struct field tags.
//
// It also includes functionality to deserialize environment variables back into
// Includes functionality to deserialize environment variables back into
// struct fields, handling pointers and nested structs appropriately, as well as providing
// shell-compatible output for environment variable definitions.
//
// Incidentally the package also defines several case conversion functions that aid in manipulating
// which is useful for generating or parsing environment variables,
// JSON tags, or command line flags style of naming (camelCase, UPPER_SNAKE_CASE, lower-kebab-case ...)
//
// The package leverages reflection to dynamically handle arbitrary struct types,
// and has 0 dependencies.
package struct2env
Expand Down

0 comments on commit d7be23c

Please sign in to comment.