geoip

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GeoIPCmd = &cobra.Command{
	Use:   "geoip",
	Short: "Lookup Geo information for an IP",
	Long:  "",
	Run: func(cmd *cobra.Command, args []string) {
		ip, err := cmd.Flags().GetString("ip")
		if err != nil {
			log.Fatalf("Error fetching flags %s", err)
		}

		if ip == "" {
			cmd.Help()
			return
		}

		record, err := maxmind.IP2Geo(ip)
		if err != nil {
			log.Fatalf("Error fetching record: %s", err)
		}

		b, err := json.MarshalIndent(record, "", "    ")
		if err != nil {
			log.Fatalf("Error parsing record: %s", err)
		}
		fmt.Println(string(b))
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL