Replying to myself:The byte conversion actually makes the masking with & unnecessary. In addition the for can use range. So an even better version is here:Regards,Ryan
On Friday, May 10, 2013 1:03:37 AM UTC-4, Ryan Leavengood wrote:func intToIP(ip_int uint64) net.IP {result := make(net.IP, 4)for i := 0; i < 4; i++ {result[i] = byte((ip_int >> uint(8 * i)) & 0xff)}return result
}
On Friday, May 10, 2013 12:38:54 AM UTC-4, Vlad Didenko wrote:
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
func inet_aton(ip string) (ip_int uint32) {ip_byte := net.ParseIP(ip).To4()for i := 0; i < len(ip_byte); i++ {ip_int |= uint32(ip_byte[i])if i < 3 {ip_int <<= 8}}return}