当前位置: 首页>>代码示例>>Golang>>正文


Golang Value.Export方法代码示例

本文整理汇总了Golang中github.com/dop251/otto.Value.Export方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.Export方法的具体用法?Golang Value.Export怎么用?Golang Value.Export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/dop251/otto.Value的用法示例。


在下文中一共展示了Value.Export方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GetBool

//GetBool gets bool from otto value
func GetBool(value otto.Value) (bool, error) {
	rawBool, _ := value.Export()
	result, ok := rawBool.(bool)
	if !ok {
		return false, fmt.Errorf(wrongArgumentType, rawBool, "bool")
	}
	return result, nil
}
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:9,代码来源:otto.go

示例2: GetAuthorization

//GetAuthorization gets Transaction from otto value
func GetAuthorization(value otto.Value) (schema.Authorization, error) {
	rawAuthorization, _ := value.Export()
	result, ok := rawAuthorization.(schema.Authorization)
	if !ok {
		return nil, fmt.Errorf(wrongArgumentType, rawAuthorization, "Authorization")
	}
	return result, nil
}
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:9,代码来源:otto.go

示例3: GetTransaction

//GetTransaction gets Transaction from otto value
func GetTransaction(value otto.Value) (transaction.Transaction, error) {
	rawTransaction, _ := value.Export()
	result, ok := rawTransaction.(transaction.Transaction)
	if !ok {
		return nil, fmt.Errorf(wrongArgumentType, rawTransaction, "Transaction")
	}
	return result, nil
}
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:9,代码来源:otto.go

示例4: GetString

//GetString gets string from otto value
func GetString(value otto.Value) (string, error) {
	rawString, _ := value.Export()
	result, ok := rawString.(string)
	if !ok {
		return "", fmt.Errorf(wrongArgumentType, rawString, "string")
	}
	return result, nil
}
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:9,代码来源:otto.go

示例5: GetList

//GetList gets []interface{} from otto value
func GetList(value otto.Value) ([]interface{}, error) {
	rawSlice, _ := value.Export()
	result, ok := rawSlice.([]interface{})
	if !ok {
		return []interface{}{}, fmt.Errorf(wrongArgumentType, rawSlice, "array")
	}
	for i, value := range result {
		result[i] = ConvertOttoToGo(value)
	}
	return result, nil
}
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:12,代码来源:otto.go

示例6: GetMap

//GetMap gets map[string]interace{} from otto value
func GetMap(value otto.Value) (map[string]interface{}, error) {
	rawMap, _ := value.Export()
	result, ok := rawMap.(map[string]interface{})
	if !ok {
		return map[string]interface{}{}, fmt.Errorf(wrongArgumentType, rawMap, "Object")
	}
	for key, value := range result {
		result[key] = ConvertOttoToGo(value)
	}
	return result, nil
}
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:12,代码来源:otto.go

示例7: GetStringList

//GetStringList gets []string  from otto value
func GetStringList(value otto.Value) ([]string, error) {
	rawSlice, _ := value.Export()
	errMessage := fmt.Errorf(wrongArgumentType, rawSlice, "array of strings")
	rawResult, ok := rawSlice.([]interface{})
	if !ok {
		return []string{}, errMessage
	}
	result := []string{}
	for _, rawItem := range rawResult {
		item, ok := rawItem.(string)
		if !ok {
			return []string{}, errMessage
		}
		result = append(result, item)
	}
	return result, nil
}
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:18,代码来源:otto.go


注:本文中的github.com/dop251/otto.Value.Export方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。