File: README.md

package info (click to toggle)
golang-github-likexian-gokit 0.24.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 720 kB
  • sloc: makefile: 5
file content (54 lines) | stat: -rw-r--r-- 885 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# GoKit - xip

IP kits for Golang development.

## Installation

    go get -u github.com/likexian/gokit

## Importing

    import (
        "github.com/likexian/gokit/xip"
    )

## Documentation

Visit the docs on [GoDoc](https://godoc.org/github.com/likexian/gokit/xip)

## Example

### Check string is a valid ip

```go
ok := xip.IsIP("1.1.1.1")
fmt.Println("1.1.1.1 is a ip:", ok)
```

### IPv4 ip2long

```go
i, err := IPv4ToLong("1.1.1.1")
if err == nil {
    fmt.Println("1.1.1.1 ip2long is:", i)
}
```

### IPv4 long2ip

```go
ip := LongToIPv4(16843009)
fmt.Println("16843009 long2ip is:", ip)
```

## License

Copyright 2012-2021 [Li Kexian](https://www.likexian.com/)

Licensed under the Apache License 2.0

## Donation

If this project is helpful, please share it with friends.

If you want to thank me, you can [give me a cup of coffee](https://www.likexian.com/donate/).