【发布时间】:2021-09-16 11:32:28
【问题描述】:
我需要传递一个结构体作为对函数的引用;但是,我不能在函数参数中使用指针 (*) 语法:
func abc(client cleintpassedasrefernce) {
// make changes in client so that it will be updated in the client actual memory location
}
type clienttobepassasref struct {
data int
name string
}
// calling abc function
object = clienttobepassasref{}
abc(object)
也许我可以创建另一个结构,例如类型对象传递结构
{
object *clienttobepassasref
}
并传递此对象并稍后在函数中访问它?
【问题讨论】: