From d7be23c78363c1348c556d011bbf22a50b36e1c2 Mon Sep 17 00:00:00 2001 From: Laurent Demailly Date: Tue, 7 Nov 2023 10:09:35 -0800 Subject: [PATCH] update readme and package header --- README.md | 7 +++++++ env.go | 20 +++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b790a76..57fd0dc 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/env.go b/env.go index e66f06c..3975e40 100644 --- a/env.go +++ b/env.go @@ -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