V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
mokeychan
V2EX  ›  Go 编程语言

请教各位,关于 Go 的反射调用方法返回值的问题, error 怎么获取?!

  •  
  •   mokeychan · 2018-11-20 22:45:27 +08:00 · 2163 次点击
    这是一个创建于 1983 天前的主题,其中的信息可能已经有所发展或是发生改变。

    func a() ([]byte, error){

    // 反射 要执行的函数为 b()
    result = funcValue.Call(params)
    return result[0].Bytes(),new err(result[1].String()) // 这样嚒?
    

    }

    func b(parmam...) ([]byte, error) { //... return []byte, err }

    2 条回复    2018-11-21 11:41:33 +08:00
    icexin
        1
    icexin  
       2018-11-21 11:10:34 +08:00   ❤️ 1
    result[1].Interface().(error)
    soulsxd
        2
    soulsxd  
       2018-11-21 11:41:33 +08:00   ❤️ 1
    retVal[1].Interface().(error)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1100 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 22:39 · PVG 06:39 · LAX 15:39 · JFK 18:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.