Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A minimalistic golang pkg to load environment variables to strct

NotificationsYou must be signed in to change notification settings

kamalshkeir/kenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get it :

go get -u github.com/kamalshkeir/kenv@latest

Example:

Struct to Fill from env
typeGlobalConfigstruct {Hoststring`kenv:"HOST|localhost"`// DEFAULT to 'localhost': if HOST not found in envPortstring`kenv:"PORT|9313"`Embedstruct {Staticbool`kenv:"EMBED_STATIC|false"`Templatesbool`kenv:"EMBED_TEMPLATES|false"`}Dbstruct {Namestring`kenv:"DB_NAME|db"`Typestring`kenv:"DB_TYPE"`// REEQUIRED: this env var is required, you will have error if emptyDSNstring`kenv:"DB_DSN|"`// NOT REQUIRED: if DB_DSN not found it's not required, it's ok to stay empty}Smtpstruct {Emailstring`kenv:"SMTP_EMAIL|"`Passstring`kenv:"SMTP_PASS|"`Hoststring`kenv:"SMTP_HOST|"`Portstring`kenv:"SMTP_PORT|"`}Profilerbool`kenv:"PROFILER|false"`Docsbool`kenv:"DOCS|false"`Logsbool`kenv:"LOGS|false"`Monitoringbool`kenv:"MONITORING|false"`}
Fill
kenv.Load(".env")// load env files and add to env vars// the command:err:=kenv.Fill(&Config)// fill struct with env vars loaded before

About

A minimalistic golang pkg to load environment variables to strct

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp