https://github.com/praserx/ipconv
Golang IP address converter (provides conversion between net.IP and integer).
https://github.com/praserx/ipconv
converter golang ipv4 ipv6
Last synced: 4 months ago
JSON representation
Golang IP address converter (provides conversion between net.IP and integer).
- Host: GitHub
- URL: https://github.com/praserx/ipconv
- Owner: praserx
- License: mit
- Created: 2018-05-15T14:20:35.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-25T11:45:48.000Z (almost 2 years ago)
- Last Synced: 2024-07-26T09:28:22.800Z (almost 2 years ago)
- Topics: converter, golang, ipv4, ipv6
- Language: Go
- Homepage:
- Size: 15.6 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ipconv
This library provides simple conversion between `net.IP` and integer (`net.IP <--> int`). As new feature, library now contains extension of `net.ParseIP` which returns also byte length of IP address on input.
I hope it will serve you well.
## Example
```go
package main
import (
"fmt"
"net"
"github.com/praserx/ipconv"
)
func main() {
if ip, version, err := ipconv.ParseIP("192.168.1.1"); err != nil && version == 4 {
fmt.Println(ipconv.IPv4ToInt(ip))
}
}
```