gobase

package module
v0.0.0-...-6a64294 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 2 Imported by: 0

README

Gobase

⚠️ This is not production-ready software yet ⚠️

Base settings tool for Golang services

Go CircleCI

Gobase help to read and convert environment variables in its initially declared types to parse into native structs. ✨

Download and install
go get github.com/2mikeg/gobase@latest
Features

You can read enviroment variables written in snakecase even if you write strucs fields as camelcase.

type Settings struct {
	ThisVariable *int
} //ThisVariable field will be search as "THIS_VARIABLE"
Example
type Settings struct {
	VarOne string
	VarTwo *int //Pointers are supported
}

func main() {
	var s Settings
	sBytes, err := gobase.BaseModel(s)
	//BaseModel return a []byte that must be unmarshal in the struct

	if err != nil {
		panic(err)
	}

	json.Unmarshal(sBytes, &s) //
}
Types
Type Support
int8 Yes
int16 Yes
int32 Yes
int64 Yes
uint8 No
uint16 No
uint32 Yes
uint64 Yes
int Yes
uint No
rune Yes
byte No
uintptr No
string Yes
bool Yes
complex64 No
complex128 No
Run tests
source scripts/test.sh

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseModel

func BaseModel(s any) ([]byte, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL