Skip to content

Get ip address with Golang on your computer/system

License

Notifications You must be signed in to change notification settings

masum0813/getipinfo

Repository files navigation

Get IP Address with Golang

Go

Get IP address(es) with go-lang is a simple command line tool to get your IP address vpn, internal, external, etc.

Usage

getipinfo -h
A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.

Usage:
  getipinfo [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  external    Get external ip information
  help        Help about any command
  internal    Get internal ip information
  version     Show ipinfo version information
  vpn         Get vpn ip information

Flags:
  -h, --help     help for getipinfo
  -t, --toggle   Help message for toggle

Use "getipinfo [command] --help" for more information about a command.

External IP:

getipinfo external
External ip address: xx.xx.xx.xx

Internal IP:

getipinfo internal
VPN ip address: 192.168.1.49

VPN IP:

getipinfo vpn
VPN ip address: xx.xx.xx.xx
  • How to install getipinfo
go install github.com/masum0813/getipinfo@latest
go get -u github.com/spf13/cobra@latest
go install github.com/spf13/cobra-cli@latest

Cobra Generator

https://github.com/spf13/cobra-cli/blob/main/README.md

https://cobra.dev

cobra-cli usage

cobra-cli init
go run main.go
cobra-cli add internal

References

https://github.com/GlenDC/go-external-ip

https://dev.to/koddr/github-action-for-release-your-go-projects-as-fast-and-easily-as-possible-20a2