本文整理匯總了Golang中github.com/ernestokarim/cb/config.Config.GetDefault方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.GetDefault方法的具體用法?Golang Config.GetDefault怎麽用?Golang Config.GetDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ernestokarim/cb/config.Config
的用法示例。
在下文中一共展示了Config.GetDefault方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: parseAttrs
func parseAttrs(data *config.Config, object string, idx int) map[string]string {
m := map[string]string{}
size := data.CountDefault("fields[%d].%s", idx, object)
for i := 0; i < size; i++ {
name := data.GetRequired("fields[%d].%s[%d].name", idx, object, i)
value := data.GetDefault("fields[%d].%s[%d].value", "", idx, object, i)
m[name] = value
}
return m
}
示例2: Parse
func Parse(data *config.Config, idx int) []*Validator {
validators := []*Validator{}
nvalidators := data.CountDefault("fields[%d].validators", idx)
for i := 0; i < nvalidators; i++ {
name := data.GetRequired("fields[%d].validators[%d].name", idx, i)
value := data.GetDefault("fields[%d].validators[%d].value", "", idx, i)
msg := data.GetDefault("fields[%d].validators[%d].msg", "", idx, i)
validator := createValidator(name, value, msg)
if validator == nil {
panic("bad validator name: " + name)
}
validators = append(validators, validator)
}
return validators
}
示例3: sassFromConfig
func sassFromConfig(c *config.Config, mode string) ([]*sassFile, error) {
var from string
if len(c.GetDefault("closure.library", "")) == 0 {
if mode == "dev" {
from = filepath.Join("app")
} else if mode == "prod" {
from = filepath.Join("temp")
}
}
files := []*sassFile{}
size := c.CountRequired("sass")
for i := 0; i < size; i++ {
src := filepath.Join(from, "styles", c.GetRequired("sass[%d].source", i))
dest := filepath.Join("temp", "styles", c.GetRequired("sass[%d].dest", i))
files = append(files, &sassFile{src, dest})
}
return files, nil
}
示例4: controller
func controller(c *config.Config, q *registry.Queue) error {
name := q.NextTask()
if name == "" {
return fmt.Errorf("first arg should be the name of the controller")
}
q.RemoveNextTask()
if !strings.Contains(name, "Ctrl") {
name = name + "Ctrl"
}
module := q.NextTask()
if module == "" {
return fmt.Errorf("second arg should be the module of the controller")
}
q.RemoveNextTask()
route := q.NextTask()
q.RemoveNextTask()
data := &controllerData{
Name: name,
Module: module,
Route: route,
Filename: filepath.Join(strings.Split(module, ".")...),
AppPath: c.GetDefault("paths.app", filepath.Join("app", "scripts", "app.js")),
}
if err := writeControllerFile(data); err != nil {
return fmt.Errorf("write controller failed: %s", err)
}
if err := writeControllerTestFile(data); err != nil {
return fmt.Errorf("write controller test failed: %s", err)
}
if err := writeControllerViewFile(data); err != nil {
return fmt.Errorf("write view failed: %s", err)
}
if route != "" {
if err := writeControllerRouteFile(data); err != nil {
return fmt.Errorf("write route failed: %s", err)
}
}
return nil
}
示例5: parseFields
func parseFields(data *config.Config, spec string) []*field {
fields := []*field{}
size := data.CountRequired("%s", spec)
for i := 0; i < size; i++ {
field := &field{
Key: data.GetDefault("%s[%d].key", "", spec, i),
Kind: data.GetRequired("%s[%d].kind", spec, i),
Store: data.GetDefault("%s[%d].store", "", spec, i),
Condition: data.GetDefault("%s[%d].condition", "", spec, i),
Validators: make([]*validator, 0),
}
if field.Kind == "Array" || field.Kind == "Object" || field.Kind == "Conditional" {
newSpec := fmt.Sprintf("%s[%d].fields", spec, i)
field.Fields = parseFields(data, newSpec)
}
validatorsSize := data.CountDefault("%s[%d].validators", spec, i)
for j := 0; j < validatorsSize; j++ {
v := &validator{
Name: data.GetRequired("%s[%d].validators[%d].name", spec, i, j),
Value: data.GetDefault("%s[%d].validators[%d].value", "", spec, i, j),
}
usesSize := data.CountDefault("%s[%d].validators[%d].use", spec, i, j)
for k := 0; k < usesSize; k++ {
value := data.GetDefault("%s[%d].validators[%d].use[%d]", "", spec, i, j, k)
v.Uses = append(v.Uses, value)
}
field.Validators = append(field.Validators, v)
}
fields = append(fields, field)
}
return fields
}
示例6: readServeConfig
func readServeConfig(c *config.Config) (*serveConfig, error) {
sc := &serveConfig{
base: true,
url: c.GetDefault("serve.url", "http://localhost:8080/"),
}
method := c.GetDefault("serve.base", "")
if method != "" && method != "proxy" && method != "cb" {
return nil, fmt.Errorf("serve.base config must be 'proxy' (default) or 'cb'")
}
sc.base = (method == "cb")
size := c.CountDefault("serve.proxy")
for i := 0; i < size; i++ {
pc := proxyConfig{
host: fmt.Sprintf("%s:%d", c.GetRequired("serve.proxy[%d].host", i), *config.Port),
url: c.GetRequired("serve.proxy[%d].url", i),
}
sc.proxy = append(sc.proxy, pc)
}
return sc, nil
}
示例7: build
func build(c *config.Config, q *registry.Queue) error {
q.AddTasks([]string{
"update:[email protected]",
"[email protected]",
"dist:[email protected]",
"recess:[email protected]",
"sass:[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"dist:[email protected]",
})
deploy := c.GetDefault("deploy.mode", "")
if len(deploy) > 0 {
q.AddTask(fmt.Sprintf("deploy:%s", deploy))
}
return nil
}