<p>Hi,</p>
<p>I'm fairly new to Go, and I came across a function declaration that I don't understand. Is someone able to explain it to me?</p>
<p>The <a href="https://github.com/kubernetes/ingress-nginx/blob/c49c17eb915eb17232dbd5572a3a8c9c214de5b9/internal/ingress/status/status.go#L302" rel="nofollow">snippet</a> is:</p>
<pre><code>func (s *statusSync) updateStatus(newIngressPoint []apiv1.LoadBalancerIngress) {
...
}
</code></pre>
<p>I can see that it's a function called "updateStatus" with a parameter which is an array of apiv1.LoadBalancerIngress and that there doesn't appear to be a return type.</p>
<p>What does the <code>(s *statusSync)</code> part mean? </p>
<hr/>**评论:**<br/><br/>nevyn: <pre><p><a href="http://golangtutorials.blogspot.com/2011/06/methods-on-structs.html" rel="nofollow">http://golangtutorials.blogspot.com/2011/06/methods-on-structs.html</a></p></pre>chalk_nz: <pre><p>Perfect, thank you :)</p></pre>arrans: <pre><p>Keep in mind that methods aren't limited to structs as the above URL suggests. A broader introduction is available in the Go tour: <a href="https://tour.golang.org/methods/1" rel="nofollow">https://tour.golang.org/methods/1</a></p></pre>barryzzzzzz: <pre><p>(s *statusSync) called receiver. </p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传