Skip to content

shamsher31/goip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goip

Godoc Build Status MIT License

Tiny utility to deal with IP

How to install

go get github.com/shamsher31/goip

How to use

package main

import (
  "fmt"
  "github.com/shamsher31/goip"
  "net/http"
)

func reqHandler(w http.ResponseWriter, req *http.Request) {
  // Returns 1.187.109.235, nil
  fmt.Println(ip.Remote(req))
}

func main() {
  // Returns 10.102.29.20, nil
  fmt.Println(ip.Local())

  // Run simple server to test
  http.HandleFunc("/", reqHandler)
  http.ListenAndServe(":8090", nil)
}

Why

This package will be useful when you write application which require you to deal with local or remote IP of the requested host.

License

MIT © Shamsher Ansari

About

Tiny utility to deal with IP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages