cherry-game / hotfix Goto Github PK
View Code? Open in Web Editor NEW在运行时支持热刷go脚本,可动态替换函数、属性。
在运行时支持热刷go脚本,可动态替换函数、属性。
phantacix,你好:
想要替换的是业务处理的函数,它会有一些第三方的依赖,如:
github.com/golang/protobuf/proto
xxx.com/root/DawnCore/basic //自建的项目公共库,里面包含日志类
。。。
而且还用到一些全局变量,如日志,连接器对象等,xxx.com是公司域名,有点敏感,就用xxx.com代替了
在项目中写一个例子尝试了下,会报错:
[2023-11-09 11:21:00,222][0 0 Error 7 1]hotfixdo.go:19 hotfix.ApplyFunc(),err=./_patch_files/patch/patch.go:8:2: import "xxx.com/root/DawnCore/basic" error: unable to find source related to: "xxx.com/root/DawnCore/basic". Either the GOPATH environment variable, or the Interpreter.Options.GoPath needs to be set
`package patch
import (
"fmt"
"reflect"
"github.com/golang/protobuf/proto"
"xxx.com/root/DawnCore/basic"
"xxx.com/root/DawnFriend/hotfix"
"xxx.com/root/DawnFriend/impl"
"xxx.com/root/DawnMicroHub"
"xxx.com/root/DawnMicroHub/econnector"
"xxx.com/root/DawnMicroHub/proto/csmsg"
)
func GetPatch() *hotfix.FuncPatch {
fmt.Println("invoke GetPatch()")
fn := func(handler *impl.MSG_FRIEND_APPLY_AGREE_ALL_REQ, ec econnector.IExchangeConnector, req *DawnMicroHub.Packet) {
msg := &csmsg.TMSG_FRIEND_APPLY_AGREE_ALL_REQ{}
err := proto.Unmarshal(req.Data, msg)
if err != nil {
basic.Log.Error("roldId=", req.RoleID, ",err=", err.Error())
return
}
basic.Log.Debug("new func(), roldId=", req.RoleID, ",HandleFriendApplyAgreeAllReq() req msg=", msg.String())
return
}
return &hotfix.FuncPatch{
StructType: reflect.TypeOf(&impl.TMSG_FRIEND_APPLY_AGREE_ALL_REQ{}),
FuncName: "HandleFriendApplyAgreeAllReq",
FuncValue: reflect.ValueOf(fn),
}
}
`
是我的写法不对吗?还是需要把整个xxx.com/root/DawnCore的源码都要放到patch文件夹?这样不太可取,有泄露源代码的风险
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.