<div dir="ltr">Well, his wasn't even using net.ParseIP ;)<div><br></div><div>I do like that you don't need to do the nil check from ParseIP before doing To4().... I didn't think to check if you needed the nil check. That's one aspect of Go's methods that is so awesome. Calling methods on a nil value doesn't cause a panic in and of itself.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 4, 2014 at 4:07 PM, Gustavo Niemeyer <span dir="ltr"><<a href="mailto:gustavo@niemeyer.net" target="_blank">gustavo@niemeyer.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>I generally just "hand code" that sort of logic as well:</div><div><br></div><div> <a href="http://play.golang.org/p/Hvi9t_ZFlw" target="_blank">http://play.golang.org/p/Hvi9t_ZFlw</a></div><div><br></div><div>and yeah, big-endian is the "network byte order". Technically, anything would work (XOR it with 42!), but it would be surprising.</div><div><br></div><div><br></div><div><br></div><div><br></div><br><div class="gmail_quote"><div><div class="h5">On Thu Dec 04 2014 at 5:50:13 PM Nate Finch <<a href="mailto:nate.finch@canonical.com" target="_blank">nate.finch@canonical.com</a>> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><a href="http://play.golang.org/p/H1DI2Bw1OY" target="_blank">http://play.golang.org/p/H1DI2Bw1OY</a><br></div><div><br></div><div>Michael was working on translating an ipv4 strings to uint32 (he said int, but I hope he meant uint32). He was hand coding it, but I figured there was a better way using the built-in libraries. Turns out it's not too bad. The code is in the link above. I thought it was interesting, so I'm cc'ing juju-dev.</div><div><br></div><div>The only thing I wasn't sure about was BigEndian vs. LittleEndian. IMO, 0.0.0.5 -> 5 makes the most sense, so I went with BigEndian. I suppose it doesn't matter as long as the conversions are kept consistent in both directions.</div><div><br></div><div>-Nate</div></div></div></div><span class="HOEnZb"><font color="#888888">
--<br>
Juju-dev mailing list<br>
<a href="mailto:Juju-dev@lists.ubuntu.com" target="_blank">Juju-dev@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/juju-dev" target="_blank">https://lists.ubuntu.com/<u></u>mailman/listinfo/juju-dev</a><br>
</font></span></blockquote></div>
</blockquote></div><br></div>