Skip to content
/ ipip Public

Golang wrapper for ipip.net ipdb file and free API

Notifications You must be signed in to change notification settings

Delphier/ipip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipip

Golang wrapper for ipip.net ipdb file and free API

Install

go get github.com/delphier/ipip

Example: ipdb file

if err := ipip.Open("./ipipfree.ipdb"); err != nil {
    log.Fatal(err)
}
// or
// ipip.FatalOpen("./ipipfree.ipdb")

fmt.Println(ipip.Get("118.28.8.8"))     // Output: 天津
fmt.Println(ipip.Get("211.143.12.218")) // Output: 湖南 邵阳
fmt.Println(ipip.Get("67.230.161.196")) // Output: 美国
fmt.Println(ipip.Get("::1"))            // Output: 

Example: free API

fmt.Println(ipip.APIGet("118.28.8.8"))     // Output: 天津
fmt.Println(ipip.APIGet("211.143.12.218")) // Output: 湖南 邵阳
fmt.Println(ipip.APIGet("67.230.161.196")) // Output: 美国 加利福尼亚州 洛杉矶
fmt.Println(ipip.APIGet("::1"))            // Output: 保留地址

About

Golang wrapper for ipip.net ipdb file and free API

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages