Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gengine 支持返回多值吗 类似 value,error #40

Open
RuiFG opened this issue Jan 7, 2022 · 1 comment
Open

gengine 支持返回多值吗 类似 value,error #40

RuiFG opened this issue Jan 7, 2022 · 1 comment

Comments

@RuiFG
Copy link

RuiFG commented Jan 7, 2022

有时候需要判断是否有error 再执行相关逻辑逻辑
希望还是

value,err = function()
if ! isNil(err){
 //do something
}
@Jun10ng
Copy link

Jun10ng commented Jan 10, 2022

可以返回多值的。只不过他是返回在一个ResultsMap中,你可以通过判断ResultsMap内的所有value是否都为false来实现。

	err,result := svc.Pool.ExecuteConcurrent(reqData)
	if err != nil{
		logger.LogInfof("Execute err:%s ", err)
		return err
	}
	for ruleName, v := range result{
		if v.(bool){
			continue
		}
		return fmt.Errorf("ruleName:[%v] result is false",ruleName)
	}

可以看下官方文档

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants