Giter Club home page Giter Club logo

hotfix's People

Contributors

phantacix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hotfix's Issues

被替换的函数中如果包含第三方依赖怎么处理?

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文件夹?这样不太可取,有泄露源代码的风险

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.