https://github.com/ableinc/myip
Fetch your public IPv4 or IPv6 address from the command line
https://github.com/ableinc/myip
command-line go golang ip ip-address ip-address-lookup ip-lookup terminal
Last synced: about 1 month ago
JSON representation
Fetch your public IPv4 or IPv6 address from the command line
- Host: GitHub
- URL: https://github.com/ableinc/myip
- Owner: ableinc
- Created: 2024-12-06T23:51:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-16T14:39:07.000Z (over 1 year ago)
- Last Synced: 2025-03-16T15:28:09.416Z (over 1 year ago)
- Topics: command-line, go, golang, ip, ip-address, ip-address-lookup, ip-lookup, terminal
- Language: Go
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# myip
A fast CLI tool that shows your public IP address along with optional geolocation details and local weather — powered by [Cloudflare Radar](https://radar.cloudflare.com) and [Open-Meteo](https://open-meteo.com).
## Requirements
- Go 1.23+
## Build
```bash
git clone
cd myip
make build
```
The binary is written to `./myip`. Move it somewhere on your `$PATH`:
```bash
mv myip ~/.local/bin/
```
To build a specific version:
```bash
make build VERSION=1.0.0
```
The `-w -s` ldflags are applied by default (strips debug info for a smaller binary).
## Add to PATH
```zsh
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
```bash
# 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](https://staticcheck.io) — install with `go install honnef.co/go/tools/cmd/staticcheck@latest` |
| `make security` | Run [govulncheck](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck) — install with `go install golang.org/x/vuln/cmd/govulncheck@latest` |
| `make version` | Print the current version |
## Data sources
- **IP info** — `https://ipv4-check-perf.radar.cloudflare.com/api/info`
- **Weather** — `https://api.open-meteo.com` (no API key required)