package main

import (
	"flag"
	"fmt"
	"log"
	"net"

	"github.com/umahmood/geoip"
)

// command line flags.
var ip string

func init() {
	flag.StringVar(&ip, "ip", "", "IP to geo locate can be v4 or v6 address.")
	flag.Parse()

	if ip != "" {
		addr := net.ParseIP(ip)
		if addr == nil {
			log.Fatalln("not a valid IP address.")
		}
	}
}

func main() {
	loc, err := geoip.Location(ip)
	if err != nil {
		log.Fatalln(err)
	}

	for k, v := range loc {
		fmt.Println(k, ":", v)
	}
}

package main

import (
	"flag"
	"fmt"
	"log"

	"github.com/umahmood/geoip"
)

// command line flags.
var ip string

func init() {
	flag.StringVar(&ip, "ip", "", "IP to geo locate can be v4/v6 address or domain name.")
	flag.Parse()
}

func main() {
	loc, err := geoip.Location(ip)
	if err != nil {
		log.Fatalln(err)
	}

	for k, v := range loc {
		fmt.Println(k, ":", v)
	}
}

Remove check to see if -ip flag is valid address format
Remove check to see if -ip flag is valid address format

geoip previously used telize api for lookups, it only accepted ip addresses. Now we have
switched to freegeoip the api can accept domain names as well as ip addresses. geoip now
allows the user to pass in domain names.
