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


Golang gohanscript.RegisterStmtParser函数代码示例

本文整理汇总了Golang中github.com/cloudwan/gohan/extension/gohanscript.RegisterStmtParser函数的典型用法代码示例。如果您正苦于以下问题:Golang RegisterStmtParser函数的具体用法?Golang RegisterStmtParser怎么用?Golang RegisterStmtParser使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: init

func init() {

	gohanscript.RegisterStmtParser("split",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"value", "sep")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var value string
				ivalue := stmt.Arg("value", context)
				if ivalue != nil {
					value = ivalue.(string)
				}
				var sep string
				isep := stmt.Arg("sep", context)
				if isep != nil {
					sep = isep.(string)
				}

				result1,
					err :=
					lib.Split(
						value, sep)

				return result1, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("Split",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			value := args[0].(string)
			sep := args[1].(string)

			result1,
				err :=
				lib.Split(
					value, sep)
			return []interface{}{
				result1,
				err}

		})

	gohanscript.RegisterStmtParser("join",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"value", "sep")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var value []interface{}
				ivalue := stmt.Arg("value", context)
				if ivalue != nil {
					value = ivalue.([]interface{})
				}
				var sep string
				isep := stmt.Arg("sep", context)
				if isep != nil {
					sep = isep.(string)
				}

				result1,
					err :=
					lib.Join(
						value, sep)

				return result1, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("Join",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			value := args[0].([]interface{})
			sep := args[0].(string)

			result1,
				err :=
				lib.Join(
					value, sep)
			return []interface{}{
				result1,
				err}

		})

}
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:93,代码来源:lib_string.go

示例2: init

func init() {
	gohanscript.RegisterStmtParser("http_server", httpServer)
}
开发者ID:vozhyk-,项目名称:gohan,代码行数:3,代码来源:httpserver.go

示例3: init

func init() {

	gohanscript.RegisterStmtParser("http_get",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var url string
				iurl := stmt.Arg("url", context)
				if iurl != nil {
					url = iurl.(string)
				}
				var headers map[string]interface{}
				iheaders := stmt.Arg("headers", context)
				if iheaders != nil {
					headers = iheaders.(map[string]interface{})
				}

				result1,
					err :=
					lib.HTTPGet(
						url, headers)

				return result1, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("HTTPGet",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			url, _ := args[0].(string)
			headers, _ := args[0].(map[string]interface{})

			result1,
				err :=
				lib.HTTPGet(
					url, headers)
			return []interface{}{
				result1,
				err}

		})

	gohanscript.RegisterStmtParser("http_post",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var url string
				iurl := stmt.Arg("url", context)
				if iurl != nil {
					url = iurl.(string)
				}
				var headers map[string]interface{}
				iheaders := stmt.Arg("headers", context)
				if iheaders != nil {
					headers = iheaders.(map[string]interface{})
				}
				var postData map[string]interface{}
				ipostData := stmt.Arg("post_data", context)
				if ipostData != nil {
					postData = ipostData.(map[string]interface{})
				}

				result1,
					err :=
					lib.HTTPPost(
						url, headers, postData)

				return result1, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("HTTPPost",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			url, _ := args[0].(string)
			headers, _ := args[0].(map[string]interface{})
			postData, _ := args[0].(map[string]interface{})

			result1,
				err :=
				lib.HTTPPost(
					url, headers, postData)
			return []interface{}{
				result1,
				err}

		})

	gohanscript.RegisterStmtParser("http_put",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var url string
				iurl := stmt.Arg("url", context)
				if iurl != nil {
					url = iurl.(string)
				}
				var headers map[string]interface{}
				iheaders := stmt.Arg("headers", context)
				if iheaders != nil {
//.........这里部分代码省略.........
开发者ID:vozhyk-,项目名称:gohan,代码行数:101,代码来源:lib_http.go

示例4: init

func init() {
	gohanscript.RegisterStmtParser("job", backgroundJob)
}
开发者ID:vozhyk-,项目名称:gohan,代码行数:3,代码来源:job.go

示例5: init

func init() {

	gohanscript.RegisterStmtParser("fetch_content",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var path string
				ipath := stmt.Arg("path", context)
				if ipath != nil {
					path = ipath.(string)
				}

				result1,
					err :=
					lib.FetchContent(
						path)

				return result1, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("FetchContent",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			path, _ := args[0].(string)

			result1,
				err :=
				lib.FetchContent(
					path)
			return []interface{}{
				result1,
				err}

		})

	gohanscript.RegisterStmtParser("save_content",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var path string
				ipath := stmt.Arg("path", context)
				if ipath != nil {
					path = ipath.(string)
				}
				var data interface{}
				idata := stmt.Arg("data", context)
				if idata != nil {
					data = idata.(interface{})
				}

				err :=
					lib.SaveContent(
						path, data)

				return nil, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("SaveContent",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			path, _ := args[0].(string)
			data, _ := args[0].(interface{})

			err :=
				lib.SaveContent(
					path, data)
			return []interface{}{
				err}

		})

}
开发者ID:vozhyk-,项目名称:gohan,代码行数:74,代码来源:lib_file.go

示例6: init

func init() {

	gohanscript.RegisterStmtParser("make_queue",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"workers")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var workers int
				iworkers := stmt.Arg("workers", context)
				if iworkers != nil {
					workers = iworkers.(int)
				}

				result1 :=
					lib.MakeQueue(
						workers)

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("MakeQueue",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			workers := args[0].(int)

			result1 :=
				lib.MakeQueue(
					workers)
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("wait_queue",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"queue")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var queue *job.Queue
				iqueue := stmt.Arg("queue", context)
				if iqueue != nil {
					queue = iqueue.(*job.Queue)
				}

				lib.WaitQueue(
					queue)
				return nil, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("WaitQueue",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			queue := args[0].(*job.Queue)

			lib.WaitQueue(
				queue)
			return nil

		})

	gohanscript.RegisterStmtParser("stop",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"queue")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var queue *job.Queue
				iqueue := stmt.Arg("queue", context)
				if iqueue != nil {
					queue = iqueue.(*job.Queue)
				}

				lib.Stop(
					queue)
				return nil, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("Stop",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			queue := args[0].(*job.Queue)

			lib.Stop(
				queue)
			return nil

//.........这里部分代码省略.........
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:101,代码来源:lib_job.go

示例7: init

func init() {

	gohanscript.RegisterStmtParser("make_map",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				result1 :=
					lib.MakeMap()

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("MakeMap",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			result1 :=
				lib.MakeMap()
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("map_set",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var m cmap.ConcurrentMap
				im := stmt.Arg("m", context)
				if im != nil {
					m = im.(cmap.ConcurrentMap)
				}
				var key string
				ikey := stmt.Arg("key", context)
				if ikey != nil {
					key = ikey.(string)
				}
				var value interface{}
				ivalue := stmt.Arg("value", context)
				if ivalue != nil {
					value = ivalue.(interface{})
				}

				lib.MapSet(
					m, key, value)
				return nil, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("MapSet",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			m, _ := args[0].(cmap.ConcurrentMap)
			key, _ := args[0].(string)
			value, _ := args[0].(interface{})

			lib.MapSet(
				m, key, value)
			return nil

		})

	gohanscript.RegisterStmtParser("map_get",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var m cmap.ConcurrentMap
				im := stmt.Arg("m", context)
				if im != nil {
					m = im.(cmap.ConcurrentMap)
				}
				var key string
				ikey := stmt.Arg("key", context)
				if ikey != nil {
					key = ikey.(string)
				}

				result1 :=
					lib.MapGet(
						m, key)

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("MapGet",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			m, _ := args[0].(cmap.ConcurrentMap)
			key, _ := args[0].(string)

			result1 :=
				lib.MapGet(
					m, key)
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("map_has",
//.........这里部分代码省略.........
开发者ID:vozhyk-,项目名称:gohan,代码行数:101,代码来源:lib_atomic.go

示例8: init

func init() {

	gohanscript.RegisterStmtParser("uuid",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				result1 :=
					lib.UUID()

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("UUID",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			result1 :=
				lib.UUID()
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("format_uuid",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var uuid string
				iuuid := stmt.Arg("uuid", context)
				if iuuid != nil {
					uuid = iuuid.(string)
				}

				result1,
					err :=
					lib.FormatUUID(
						uuid)

				return result1, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("FormatUUID",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			uuid, _ := args[0].(string)

			result1,
				err :=
				lib.FormatUUID(
					uuid)
			return []interface{}{
				result1,
				err}

		})

	gohanscript.RegisterStmtParser("env",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				result1 :=
					lib.Env()

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("Env",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			result1 :=
				lib.Env()
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("normalize_map",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var data map[string]interface{}
				idata := stmt.Arg("data", context)
				if idata != nil {
					data = idata.(map[string]interface{})
				}

				result1 :=
					lib.NormalizeMap(
						data)

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("NormalizeMap",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			data, _ := args[0].(map[string]interface{})
//.........这里部分代码省略.........
开发者ID:vozhyk-,项目名称:gohan,代码行数:101,代码来源:lib_util.go

示例9: init

func init() {

	gohanscript.RegisterStmtParser("get_test_server_url",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"server")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var server *httptest.Server
				iserver := stmt.Arg("server", context)
				if iserver != nil {
					server = iserver.(*httptest.Server)
				}

				result1 :=
					lib.GetTestServerURL(
						server)

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("GetTestServerURL",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			server := args[0].(*httptest.Server)

			result1 :=
				lib.GetTestServerURL(
					server)
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("stop_test_server",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"server")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var server *httptest.Server
				iserver := stmt.Arg("server", context)
				if iserver != nil {
					server = iserver.(*httptest.Server)
				}

				lib.StopTestServer(
					server)
				return nil, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("StopTestServer",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			server := args[0].(*httptest.Server)

			lib.StopTestServer(
				server)
			return nil

		})

	gohanscript.RegisterStmtParser("gohan_server",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"config_file", "test")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var configFile string
				iconfigFile := stmt.Arg("config_file", context)
				if iconfigFile != nil {
					configFile = iconfigFile.(string)
				}
				var test bool
				itest := stmt.Arg("test", context)
				if itest != nil {
					test = itest.(bool)
				}

				result1,
					err :=
					lib.GohanServer(
						configFile, test)

				return result1, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("GohanServer",
//.........这里部分代码省略.........
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:101,代码来源:lib_httpserver.go

示例10: init

func init() {

	gohanscript.RegisterStmtParser("ip_to_int",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"ip")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var ip string
				iip := stmt.Arg("ip", context)
				if iip != nil {
					ip = iip.(string)
				}

				result1 :=
					lib.IPToInt(
						ip)

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("IPToInt",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			ip := args[0].(string)

			result1 :=
				lib.IPToInt(
					ip)
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("int_to_ip",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"value")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var value int
				ivalue := stmt.Arg("value", context)
				if ivalue != nil {
					value = ivalue.(int)
				}

				result1 :=
					lib.IntToIP(
						value)

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("IntToIP",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			value := args[0].(int)

			result1 :=
				lib.IntToIP(
					value)
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("ip_add",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"ip", "value")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var ip string
				iip := stmt.Arg("ip", context)
				if iip != nil {
					ip = iip.(string)
				}
				var value int
				ivalue := stmt.Arg("value", context)
				if ivalue != nil {
					value = ivalue.(int)
				}

				result1 :=
					lib.IPAdd(
						ip, value)

				return result1, nil

//.........这里部分代码省略.........
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:101,代码来源:lib_iputil.go

示例11: init

func init() {

	gohanscript.RegisterStmtParser("gohan_schema",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var schemaID string
				ischemaID := stmt.Arg("schema_id", context)
				if ischemaID != nil {
					schemaID = ischemaID.(string)
				}

				result1,
					err :=
					lib.GohanSchema(
						schemaID)

				return result1, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("GohanSchema",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			schemaID, _ := args[0].(string)

			result1,
				err :=
				lib.GohanSchema(
					schemaID)
			return []interface{}{
				result1,
				err}

		})

	gohanscript.RegisterStmtParser("gohan_schemas",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				result1 :=
					lib.GohanSchemas()

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("GohanSchemas",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			result1 :=
				lib.GohanSchemas()
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("gohan_policies",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				result1 :=
					lib.GohanPolicies()

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("GohanPolicies",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			result1 :=
				lib.GohanPolicies()
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("read_config",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var path string
				ipath := stmt.Arg("path", context)
				if ipath != nil {
					path = ipath.(string)
				}

				err :=
					lib.ReadConfig(
						path)

				return nil, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("ReadConfig",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			path, _ := args[0].(string)
//.........这里部分代码省略.........
开发者ID:vozhyk-,项目名称:gohan,代码行数:101,代码来源:lib_gohan.go

示例12: init

func init() {

	gohanscript.RegisterStmtParser("get_openstack_client",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"auth_url", "user_name", "password", "domain_name", "tenant_name", "version")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var authURL string
				iauthURL := stmt.Arg("auth_url", context)
				if iauthURL != nil {
					authURL = iauthURL.(string)
				}
				var userName string
				iuserName := stmt.Arg("user_name", context)
				if iuserName != nil {
					userName = iuserName.(string)
				}
				var password string
				ipassword := stmt.Arg("password", context)
				if ipassword != nil {
					password = ipassword.(string)
				}
				var domainName string
				idomainName := stmt.Arg("domain_name", context)
				if idomainName != nil {
					domainName = idomainName.(string)
				}
				var tenantName string
				itenantName := stmt.Arg("tenant_name", context)
				if itenantName != nil {
					tenantName = itenantName.(string)
				}
				var version string
				iversion := stmt.Arg("version", context)
				if iversion != nil {
					version = iversion.(string)
				}

				result1,
					err :=
					lib.GetOpenstackClient(
						authURL, userName, password, domainName, tenantName, version)

				return result1, err

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("GetOpenstackClient",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			authURL := args[0].(string)
			userName := args[1].(string)
			password := args[2].(string)
			domainName := args[3].(string)
			tenantName := args[4].(string)
			version := args[5].(string)

			result1,
				err :=
				lib.GetOpenstackClient(
					authURL, userName, password, domainName, tenantName, version)
			return []interface{}{
				result1,
				err}

		})

	gohanscript.RegisterStmtParser("openstack_token",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			stmtErr := stmt.HasArgs(
				"client")
			if stmtErr != nil {
				return nil, stmtErr
			}
			return func(context *gohanscript.Context) (interface{}, error) {

				var client *gophercloud.ServiceClient
				iclient := stmt.Arg("client", context)
				if iclient != nil {
					client = iclient.(*gophercloud.ServiceClient)
				}

				result1 :=
					lib.OpenstackToken(
						client)

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("OpenstackToken",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			client := args[0].(*gophercloud.ServiceClient)

			result1 :=
//.........这里部分代码省略.........
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:101,代码来源:lib_openstack.go

示例13: init

func init() {
	gohanscript.RegisterStmtParser("transaction", transactionFunc)
}
开发者ID:marcin-ptaszynski,项目名称:gohan,代码行数:3,代码来源:gohan.go

示例14: init

func init() {

	gohanscript.RegisterStmtParser("add_int",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var a int
				ia := stmt.Arg("a", context)
				if ia != nil {
					a = ia.(int)
				}
				var b int
				ib := stmt.Arg("b", context)
				if ib != nil {
					b = ib.(int)
				}

				result1 :=
					lib.AddInt(
						a, b)

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("AddInt",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			a, _ := args[0].(int)
			b, _ := args[1].(int)

			result1 :=
				lib.AddInt(
					a, b)
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("sub_int",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var a int
				ia := stmt.Arg("a", context)
				if ia != nil {
					a = ia.(int)
				}
				var b int
				ib := stmt.Arg("b", context)
				if ib != nil {
					b = ib.(int)
				}

				result1 :=
					lib.SubInt(
						a, b)

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("SubInt",
		func(vm *gohanscript.VM, args []interface{}) []interface{} {

			a, _ := args[0].(int)
			b, _ := args[1].(int)

			result1 :=
				lib.SubInt(
					a, b)
			return []interface{}{
				result1}

		})

	gohanscript.RegisterStmtParser("mul_int",
		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
			return func(context *gohanscript.Context) (interface{}, error) {

				var a int
				ia := stmt.Arg("a", context)
				if ia != nil {
					a = ia.(int)
				}
				var b int
				ib := stmt.Arg("b", context)
				if ib != nil {
					b = ib.(int)
				}

				result1 :=
					lib.MulInt(
						a, b)

				return result1, nil

			}, nil
		})
	gohanscript.RegisterMiniGoFunc("MulInt",
//.........这里部分代码省略.........
开发者ID:vozhyk-,项目名称:gohan,代码行数:101,代码来源:lib_math.go

示例15: init

func init() {
	gohanscript.RegisterStmtParser("command", command)
}
开发者ID:vozhyk-,项目名称:gohan,代码行数:3,代码来源:command.go


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