Help understanding syntax

blov · · 461 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi,</p> <p>I&#39;m fairly new to Go, and I came across a function declaration that I don&#39;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&#39;s a function called &#34;updateStatus&#34; with a parameter which is an array of apiv1.LoadBalancerIngress and that there doesn&#39;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&#39;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

461 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传