这个函数中的 (t *SimpleAsset) 是什么
What is (t *SimpleAsset) in this function
func (t *SimpleAsset) Init(stub shim.ChaincodeStubInterface) peer.Response
我一直在努力理解 hyperledger
我们使用 Go
语言来表达 Chaincode
。但是在这里我无法理解 (t* SimpleAsset)
是什么。
我明白 unit 是函数的名称,stub 部分是参数,peer.Response
是 return 类型。由于我是 Go
的新手,请帮助我谢谢。
在下面的代码中:
func (t *SimpleAsset) Init(stub shim.ChaincodeStubInterface) peer.Response
(t *SimpleAsset)
是 接收方 。 Go,与许多其他语言不同,它允许您将方法添加到 any(用户定义的)类型(包括函数!),并且您要添加方法的类型在此处引用。
请注意,此代码的作者将他的接收器命名为 t
而不是 self
或 this
之类的名称?在 Go 中没有命名接收器的特殊规则,您只需像命名参数一样命名它。
Go by example has a nice clear explanation of the basics, but the Go specification 也很有帮助。
func (t *SimpleAsset) Init(stub shim.ChaincodeStubInterface) peer.Response
我一直在努力理解 hyperledger
我们使用 Go
语言来表达 Chaincode
。但是在这里我无法理解 (t* SimpleAsset)
是什么。
我明白 unit 是函数的名称,stub 部分是参数,peer.Response
是 return 类型。由于我是 Go
的新手,请帮助我谢谢。
在下面的代码中:
func (t *SimpleAsset) Init(stub shim.ChaincodeStubInterface) peer.Response
(t *SimpleAsset)
是 接收方 。 Go,与许多其他语言不同,它允许您将方法添加到 any(用户定义的)类型(包括函数!),并且您要添加方法的类型在此处引用。
请注意,此代码的作者将他的接收器命名为 t
而不是 self
或 this
之类的名称?在 Go 中没有命名接收器的特殊规则,您只需像命名参数一样命名它。
Go by example has a nice clear explanation of the basics, but the Go specification 也很有帮助。