golang中ip地址int string互转
package iphelperimport (
"strings"
"strconv"
"bytes"
)
func StringIpToInt(ipstring string) int {
ipSegs := strings.Split(ipstring, ".")
var ipInt int = 0
var pos uint = 24
for _, ipSeg := range ipSegs {
tempInt, _ := strconv.Atoi(ipSeg)
tempInt = tempInt > 8
}
for i := 0; i < len; i++ {
buffer.WriteString(ipSegs)
if i < len-1 {
buffer.WriteString(".")
}
}
return buffer.String()
}
页:
[1]