Go Lang reusable code bits for private projects. The intent here is to be a library for my projects or others' if they find the patterns helpful and not be an all encompassing framework to keep it simple/ use what you need only.
import _ "github.com/suared/core/infra"
The side-effects here are:
- load all the environments variables so they are available from os.Getenv standard system call in the users of the library.
- setup shared project defaults
Performs .env file search in current and previous sub-directories going back up to two sub-directories. Does expect all .env files to be in one directory when found. As it searches for the environment directory it also looks for an infra/ sub-directory which I am using in my projects to organize all environment info. Prioritizes environment files in this order:
- .env.<environmentname>.local
- .env.<environmentname>
- .env
See: github.com/joho/godotenv
Shared project defaults are also here:
- Set GOMAXPROCS
- Set Default AWS security properties
All defaults here will be low weight, mostly environment variables so that it is generailly applicable for easy setup. Can be referenced from all classes and will only run once
//import "github.com/suared/core/api"
api.StartHTTPListener(apiRoutes{})
In the example above, apiRoutes is a struct that implements the Config interface so that the API "mains()" just have to call the above to get started. All shared middleware and healthchecks will be setup here.
This is organized by environment and only a dynamodb start is there for now and will expand as needed if not specific to one api
Any common copy/ pastes to start a new API will be here and can eventually include generators. For now this has:
- .gitignore - added to the base directory
- Makefile - added to the base directory
- .env - added to the infra directory
Over time as shared tools are identified they will be moved here from sub-projects. For now, this has:
- ziptools
// import "github.com/suared/core/ziptools"
err := ziptools.GetGzipData(&buf, processdata)
// -- and/ or --
err := ziptools.GetGunzipData(&buf, StructToZip)
These zippers implement a shared pool for reuse across the runtime.