Skip to content

ableinc/myip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myip

A fast CLI tool that shows your public IP address along with optional geolocation details and local weather — powered by Cloudflare Radar and Open-Meteo.

Requirements

  • Go 1.23+

Build

git clone <repo>
cd myip
make build

The binary is written to ./myip. Move it somewhere on your $PATH:

mv myip ~/.local/bin/

To build a specific version:

make build VERSION=1.0.0

The -w -s ldflags are applied by default (strips debug info for a smaller binary).

Add to PATH

export PATH="$HOME/.local/bin:$PATH"

Usage

myip [flags]
Flag Description
--detail Show full IP geolocation info (city, region, country, ASN, colo, …)
--weather Show current weather at your detected IP location
--local Show the computer's local IPv4 and IPv6 addresses (cannot be combined with --detail, --weather, --unit, or --no-cache)
--json Output as pretty-printed JSON (modifier for --detail, --weather, or --local)
--unit Temperature unit for --weather: celsius or fahrenheit (auto-detected for US and a few other countries)
--no-cache Bypass the local cache — always fetch fresh data
--help Show help and version

Examples

# Print your public IP address (default)
myip

# Full IP geolocation table
myip --detail

# Current weather at your location
myip --weather

# Both tables combined
myip --detail --weather

# IP info as JSON
myip --detail --json

# Combined JSON output
myip --detail --weather --json

# Skip cache, fetch fresh
myip --no-cache

# Force Fahrenheit
myip --weather --unit fahrenheit

# Force Celsius
myip --weather --unit celsius

# Show local IPv4 / IPv6 addresses
myip --local

# Local addresses as JSON
myip --local --json

Cache

IP geolocation results are cached at ~/.myip/cache for 30 minutes. Use --no-cache to bypass reading from and writing to the cache.

Make targets

Target Description
make build Build the binary (default)
make tidy Tidy Go module dependencies
make lint Run go vet
make staticcheck Run staticcheck — install with go install honnef.co/go/tools/cmd/staticcheck@latest
make security Run govulncheck — install with go install golang.org/x/vuln/cmd/govulncheck@latest
make version Print the current version

Data sources

  • IP infohttps://ipv4-check-perf.radar.cloudflare.com/api/info
  • Weatherhttps://api.open-meteo.com (no API key required)

About

Fetch your public IPv4 or IPv6 address from the command line

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors