<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'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't worry, working in a statically typed language takes some getting used to, but you'll get there :)</p></pre>Gooddles: <pre><p>Thank you man , I really appreciate it <3</p></pre>Gooddles: <pre><p>I took it man , thank you for the tip</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传