<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 04/12/14 21:07, Gustavo Niemeyer
wrote:<br>
</div>
<blockquote
cite="mid:CANySw1=5c8BxCWaiJaXOW5_BFOTu=88htuVE_FMLSy0Y+7H8bw@mail.gmail.com"
type="cite">
<div>I generally just "hand code" that sort of logic as well:</div>
<div><br>
</div>
<div> <a moz-do-not-send="true"
href="http://play.golang.org/p/Hvi9t_ZFlw">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>
</blockquote>
<br>
Thanks guys.<br>
<br>
Both those solutions are more elegant than mine, I was converting
the decimal digits into a hex string and then into an integer using
strconv functions. You can do that in one line of Python with list
comprehensions, but it's a bit longer in Go. It also has a bug - the
hex strings need zero padding:<br>
<br>
<a class="moz-txt-link-freetext" href="http://pastebin.ubuntu.com/9370769/">http://pastebin.ubuntu.com/9370769/</a><br>
<br>
Michael<br>
<br>
<blockquote
cite="mid:CANySw1=5c8BxCWaiJaXOW5_BFOTu=88htuVE_FMLSy0Y+7H8bw@mail.gmail.com"
type="cite">
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<br>
<div class="gmail_quote">On Thu Dec 04 2014 at 5:50:13 PM Nate
Finch <<a moz-do-not-send="true"
href="mailto:nate.finch@canonical.com">nate.finch@canonical.com</a>>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div><a moz-do-not-send="true"
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>
--<br>
Juju-dev mailing list<br>
<a moz-do-not-send="true"
href="mailto:Juju-dev@lists.ubuntu.com" target="_blank">Juju-dev@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a moz-do-not-send="true"
href="https://lists.ubuntu.com/mailman/listinfo/juju-dev"
target="_blank">https://lists.ubuntu.com/mailman/listinfo/juju-dev</a><br>
</blockquote>
</div>
</blockquote>
<br>
</body>
</html>