When to use & or * in your params?

xuanbao · · 854 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi I am currently teaching myself Golang in my spare time and one thing that keeps popping up but I cant find the documentation because I dont know what its called.</p> <p>is the * and the &amp; that is prefixed to parameters or variables, What is it or what is it called so I can try figure it out on the go docs?</p> <p>Thanks in advance!</p> <hr/>**评论:**<br/><br/>anonfunction: <pre><p>Golang allows pointers to the underlying memory of a value. This is useful because when you pass a non-pointer to a function it is copied. </p> <p>Here’s an in depth guide on the subject:</p> <p><a href="http://www.golang-book.com/books/intro/8" rel="nofollow">http://www.golang-book.com/books/intro/8</a></p> <p>I recommend reading this book in addition to the official Golang tour because it has additional information and is easy to understand for new programmers. </p></pre>aterocana: <pre><p>Actually even pointer are passed by copy, it is just the copy points to the same underlying address. Commenting just to avoid confusion in newbie.</p></pre>SeerUD: <pre><p>That is to say; everything is passed by value, pointers are values too, they just refer to the location of another value.</p></pre>twetewat: <pre><p><a href="https://tour.golang.org/moretypes/1" rel="nofollow">https://tour.golang.org/moretypes/1</a></p> <p><a href="https://dave.cheney.net/2017/04/26/understand-go-pointers-in-less-than-800-words-or-your-money-back" rel="nofollow">https://dave.cheney.net/2017/04/26/understand-go-pointers-in-less-than-800-words-or-your-money-back</a></p></pre>gotoma: <pre><p>thanks dave cheney provided a brilliant primer to get me started!</p></pre>user3961: <pre><p>Ampersand-&gt;Address</p> <p>Shit I guess Asterisk starts with A too</p></pre>lion_rouge: <pre><p>It&#39;s a star.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

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