I want to debug a go code. I want to put breakpoint on a method (belonging to a named type) in a imported package. I went through a lot of online materials where they only put breakpoints on a line number in file (eg: breakpoint a.go:15
).
I have done a lot of debugging in 'C' where I put breakpoints on functions. Is this kind of debugging possible in go??
I have the following code in my main package.
clientContext := sdk.Context(fabsdk.WithUser("Admin"), fabsdk.WithOrg("ordererorg"))
.
I want to put breakpoints to
1) function WithUser()
which belongs to package fabsdk
in file github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/context.go
.
2) method Context()
belonging to type FabricSDK
in file github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/fabsdk.go
in package fabsdk
.
Is it possible to put breakpoints to method WithUser()
and context()
or Isbreakpoints only allowed at a line number in a file?? I could use either gdb or delve or any other debugger as well.
如果您有用于构建 Go 二进制文件的github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/context.go
版本 - 例如,在您的src
或vendor
目录中 - 那么只需打开该文件,找到WithUser
函数,并在它的第一行放置一个断点。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.