gpt4 book ai didi

go - golang程序运行时是否可以重新加载动态库?

转载 作者:行者123 更新时间:2023-12-02 18:41:58 25 4
gpt4 key购买 nike

编辑:(来自评论)我正在寻找一种在程序运行时修改部分程序的方法。我编写这段代码仅作为示例。假设我们有这样一段代码:



<前>对于{
t := 时间.Now()
fmt.Print(t.Minute(), ":", t.Second(), "")
testdll.Testf()
时间. sleep (时间.秒 * 2)
}



打包testdll
进口 (
“FMMT”
)
//测试f
函数测试(){
fmt.Println("你好,我是版本 1")
}

当testdll更新到版本2并重建时,是否有可能在运行时得到这个结果?



14:29 你好,我是版本 1
14:31 你好我是版本1
14:33 你好我是版本1
14:35 你好我是版本2
14:37 你好我是版本2
14:39 你好我是版本2

最佳答案

Is it possible to reload dynamic libraries while a golang program running?

是的。请参阅https://golang.org/pkg/plugin/

Is it possible to get this result during runtime when testdll is updated to version 2 and rebuilt?

没有。

关于go - golang程序运行时是否可以重新加载动态库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57708721/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com