Documentation ¶
Overview ¶
Package env implements environment configuration utility functions.
Index ¶
- func SetConf(path string)
- func SetLocale(locale string)
- type Api
- type Configuration
- type Database
- type Environment
- type Environments
- type Export
- type Filters
- type InterceptUrl
- type Log
- type Mail
- type Mapping
- type Mappings
- type Profile
- type Secure
- type Sensitive
- type Session
- type Settings
- type Static
- type Template
- type Upload
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Configuration ¶
type Configuration struct { Settings Settings `xml:"settings"` Environments Environments `xml:"environments"` }
Configuration configuration.
type Database ¶
type Database struct { Name string `xml:"name,attr"` DriverName string `xml:"driverName"` DataSourceName string `xml:"dataSourceName"` MaxIdleConns int `xml:"maxIdleConns"` MaxOpenConns int `xml:"maxOpenConns"` }
Database database.
func ParseDatabase ¶
ParseDatabase get the database link parameters based on the environment profiles.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/comm/env" ) func main() { db, _ := env.ParseDatabase("env") fmt.Println(db.DriverName) fmt.Println(db.DataSourceName) fmt.Println(db.MaxIdleConns) fmt.Println(db.MaxOpenConns) }
Output: mysql root:root@/env_development?charset=utf8 10 100
type Environment ¶
type Environment struct { Id string `xml:"id,attr"` Databases []Database `xml:"database"` Mails []Mail `xml:"mail"` Sessions []Session `xml:"session"` Apis []Api `xml:"api"` Assets []Static `xml:"asset"` Statics []Static `xml:"static"` Developers []Static `xml:"developer"` Operations []Static `xml:"operation"` Uploads []Upload `xml:"upload"` Exports []Export `xml:"export"` Htmls []Template `xml:"html"` Templates []Template `xml:"template"` Sensitives []Sensitive `xml:"sensitive"` Logs []Log `xml:"log"` Secures []Secure `xml:"secure"` }
Environment environment.
type Environments ¶
type Environments struct { Default string `xml:"default,attr"` Environment []Environment `xml:"environment"` }
Environments environments.
type Export ¶
Export export.
func ParseExport ¶
ParseExport get the export based on the environment profiles.
type Filters ¶
type Filters struct {
InterceptUrl []InterceptUrl `xml:"intercept-url"`
}
Filters filters.
type InterceptUrl ¶
InterceptUrl interceptUrl.
type Log ¶
type Log struct { Name string `xml:"name,attr"` Priority int `xml:"priority"` Layout int `xml:"layout"` Output int `xml:"output"` Dir string `xml:"dir"` }
Log log.
type Mail ¶
type Mail struct { Name string `xml:"name,attr"` Secret string `xml:"secret"` Protocol string `xml:"protocol"` Username string `xml:"username"` Password string `xml:"password"` Host string `xml:"host"` Port string `xml:"port"` }
Mail mail.
func ParseMail ¶
ParseMail get the mail server parameters based on the environment profiles.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/comm/env" ) func main() { m, _ := env.ParseMail("env") fmt.Println(m.Secret) fmt.Println(m.Protocol) fmt.Println(m.Username) fmt.Println(m.Password) fmt.Println(m.Host) fmt.Println(m.Port) }
Output: 0ae36a2eha9p1e16 POP3 username@example.com password mail.example.com 110
type Secure ¶
type Secure struct { Name string `xml:"name,attr"` Enable bool `xml:"enable"` LoginUrl string `xml:"login-url"` ForbidUrl string `xml:"forbid-url"` SuccessUrl string `xml:"success-url"` Filters Filters `xml:"filters"` }
Secure secure.
func ParseSecure ¶
ParseSecure get the secure based on the environment profiles.
type Sensitive ¶
type Sensitive struct { Name string `xml:"name,attr"` Enable bool `xml:"enable"` Excludes string `xml:"excludes"` Values string `xml:"values"` }
Sensitive sensitive word.
func ParseSensitive ¶
ParseSensitive get the sensitive word based on the environment profiles.
type Session ¶
type Session struct { Name string `xml:"name,attr"` Addr string `xml:"addr"` Password string `xml:"password"` }
Session session.
func ParseSession ¶
ParseSession get the session based on the environment profiles.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/comm/env" ) func main() { s, _ := env.ParseSession("env") fmt.Println(s.Addr) fmt.Println(s.Password) }
Output: :6379 123456
type Settings ¶
Settings settings.
func ParseSettings ¶
ParseSettings get the settings link parameters based on the configuration file.
type Static ¶
type Static struct { Name string `xml:"name,attr"` Enable bool `xml:"enable"` URL string `xml:"url"` Dir string `xml:"dir"` Mappings Mappings `xml:"mappings"` }
Static static.
func ParseAsset ¶
ParseAsset get the asset based on the environment profiles.
func ParseDeveloper ¶
ParseDeveloper get the developer based on the environment profiles.
func ParseOperation ¶
ParseOperation get the operation based on the environment profiles.
func ParseStatic ¶
ParseStatic get the static based on the environment profiles.
type Template ¶
type Template struct { Name string `xml:"name,attr"` Enable bool `xml:"enable"` Reloaded bool `xml:"reloaded"` Dir string `xml:"dir"` Mappings Mappings `xml:"mappings"` }
Template template.
func ParseTemplate ¶
ParseTemplate get the template based on the environment profiles.