當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Config.GetInt方法代碼示例

本文整理匯總了Golang中github.com/ernestokarim/cb/config.Config.GetInt方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.GetInt方法的具體用法?Golang Config.GetInt怎麽用?Golang Config.GetInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ernestokarim/cb/config.Config的用法示例。


在下文中一共展示了Config.GetInt方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Parse

// Parse form fields
func Parse(data *config.Config, idx int) (Field, error) {
	base := &BaseField{
		ID:             data.GetRequired("fields[%d].name", idx),
		Name:           data.GetRequired("fields[%d].name", idx),
		Label:          data.GetDefault("fields[%d].label", "", idx),
		Help:           data.GetDefault("fields[%d].help", "", idx),
		Class:          utils.SplitStrList(data.GetDefault("fields[%d].class", "", idx)),
		Size:           utils.SplitStrList(data.GetDefault("fields[%d].size", "", idx)),
		LabelSize:      utils.SplitStrList(data.GetDefault("fields[%d].labelSize", "", idx)),
		Attrs:          parseAttrs(data, "attrs", idx),
		ContainerAttrs: parseAttrs(data, "containerAttrs", idx),
	}

	var field Field
	fieldType := data.GetRequired("fields[%d].type", idx)
	switch fieldType {
	case "email":
		fallthrough
	case "number":
		fallthrough
	case "password":
		fallthrough
	case "file":
		fallthrough
	case "url":
		fallthrough
	case "text":
		field = &inputField{
			BaseField:   base,
			PlaceHolder: data.GetDefault("fields[%d].placeholder", "", idx),
			Prefix:      data.GetDefault("fields[%d].prefix", "", idx),
			Type:        fieldType,
		}

	case "textarea":
		field = &textAreaField{
			BaseField:   base,
			PlaceHolder: data.GetDefault("fields[%d].placeholder", "", idx),
			Rows:        data.GetInt("fields[%d].rows", 3, idx),
		}

	case "submit":
		field = &submitField{
			BaseField: base,
		}

	case "datepicker":
		field = &datepickerField{
			BaseField:   base,
			PlaceHolder: data.GetDefault("fields[%d].placeholder", "", idx),
			DateFormat:  data.GetDefault("fields[%d].dateFormat", "dd/MM/yyyy", idx),
			IsOpen:      data.GetDefault("fields[%d].isOpen", "", idx),
			Options:     data.GetDefault("fields[%d].options", "", idx),
		}

	case "static":
		field = &staticField{
			BaseField: base,
			Content:   data.GetDefault("fields[%d].content", "", idx),
		}

	case "custom":
		field = &customField{
			BaseField: base,
			Content:   data.GetDefault("fields[%d].content", "", idx),
		}
		/*
		   case "select":
		     field = &selectField{
		       BaseField: base,
		       BlankID:     data.GetDefault("fields[%d].blank.id", "", idx),
		       BlankLabel:  data.GetDefault("fields[%d].blank.label", "", idx),
		       Class:       strings.Split(data.GetDefault("fields[%d].class", "", idx), " "),
		       Size:        strings.Split(data.GetDefault("fields[%d].size", "", idx), " "),
		       Help:        data.GetDefault("fields[%d].help", "", idx),
		       ID:          name,
		       Origin:      data.GetRequired("fields[%d].origin", idx),
		       OriginID:    data.GetDefault("fields[%d].originID", "id", idx),
		       OriginLabel: data.GetDefault("fields[%d].originLabel", "label", idx),
		       Watch:       data.GetDefault("fields[%d].watch", "", idx),
		     }*/

	case "checkbox":
		field = &checkboxField{
			BaseField: base,
		}

	default:
		return nil, fmt.Errorf("no field type %s in html mode", fieldType)
	}
	return field, nil
}
開發者ID:ernestoalejo,項目名稱:cb,代碼行數:93,代碼來源:parse.go


注:本文中的github.com/ernestokarim/cb/config.Config.GetInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。