-
-
Save scottdware/43662077d7f9f6c4d220 to your computer and use it in GitHub Desktop.
Azure IPs printed to console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/xml" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"os" | |
) | |
type AzurePublicIPAddresses struct { | |
Region []Region `xml:"Region"` | |
} | |
type Region struct { | |
Name string `xml:"Name,attr"` | |
Subnets []Subnet `xml:"IpRange"` | |
} | |
type Subnet struct { | |
Subnet string `xml:"Subnet,attr"` | |
} | |
func main() { | |
var azure AzurePublicIPAddresses | |
x, err := ioutil.ReadFile(os.Args[1]) | |
if err != nil { | |
log.Fatal(err) | |
} | |
if err := xml.Unmarshal(x, &azure); err != nil { | |
log.Fatal(err) | |
} | |
for _, r := range azure.Region { | |
fmt.Printf("%+v\n", r.Name) | |
for _, s := range r.Subnets { | |
fmt.Printf("--> %+v\n", s.Subnet) | |
} | |
fmt.Print("\n") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment