How to make a list ?

agolangf · · 1157 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I made a udp server and I want to make a list of the ip addresses (useraddr)</p> <pre><code> ....... ....... _, useraddr, err := ServerConn.ReadFromUDP(msg) fmt.Println(useraddr) ....... ....... </code></pre> <p>I googled but I found lists , slices, arrays and I don&#39;t know the difference .</p> <p>Thank you :)</p> <hr/>**评论:**<br/><br/>drvd: <pre><p>Take the Tour, especially from here on: <a href="https://tour.golang.org/moretypes/6" rel="nofollow">https://tour.golang.org/moretypes/6</a></p></pre>Gooddles: <pre><p>look : players := []string{useraddr} I made this slice but it show an error : Cannot use useraddr (type *net.UDPAddr) as type string in array or slice literal</p></pre>TheMerovius: <pre><p><code>players := []*net.UDPAddr{useraddr}</code></p> <p>Don&#39;t worry, working in a statically typed language takes some getting used to, but you&#39;ll get there :)</p></pre>Gooddles: <pre><p>Thank you man , I really appreciate it &lt;3</p></pre>Gooddles: <pre><p>I took it man , thank you for the tip</p></pre>

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

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