Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shamsher31/goip
Tiny utility to deal with IP
https://github.com/shamsher31/goip
Last synced: 4 days ago
JSON representation
Tiny utility to deal with IP
- Host: GitHub
- URL: https://github.com/shamsher31/goip
- Owner: shamsher31
- License: mit
- Created: 2016-02-21T15:50:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-09-13T09:45:36.000Z (about 1 year ago)
- Last Synced: 2024-06-20T16:41:47.438Z (5 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# goip
[![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/shamsher31/goip)
[![Build Status](https://travis-ci.org/shamsher31/goip.svg)](https://travis-ci.org/shamsher31/goip)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](license)Tiny utility to deal with IP
### How to install
```go
go get github.com/shamsher31/goip
```### How to use
```go
package mainimport (
"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](https://github.com/shamsher31)