<commit_before>package main

import (
	"fmt"
	"github.com/rackspace/gophercloud/openstack/compute/servers"
	"github.com/rackspace/gophercloud/openstack/identity"
	"github.com/rackspace/gophercloud/openstack/utils"
)

func main() {
	ao, err := utils.AuthOptions()
	if err != nil {
		panic(err)
	}

	a, err := identity.Authenticate(ao)
	if err != nil {
		panic(err)
	}

	sc, err := identity.GetServiceCatalog(a)
	if err != nil {
		panic(err)
	}

	ep, err := findAnyComputeEndpoint(sc)
	if err != nil {
		panic(err)
	}

	client := servers.NewClient(ep, a, ao)

	listResults, err := servers.List(client)
	if err != nil {
		panic(err)
	}

	svrs, err := servers.GetServers(listResults)
	if err != nil {
		panic(err)
	}

	for _, s := range svrs {
		fmt.Printf("ID(%s)\n", s.Id)
		fmt.Printf("    Name(%s)\n", s.Name)
		fmt.Printf("    IPv4(%s)\n    IPv6(%s)\n", s.AccessIPv4, s.AccessIPv6)
	}
	fmt.Printf("--------\n%d servers listed.\n", len(svrs))
}


func findAnyComputeEndpoint(sc *identity.ServiceCatalog) (string, error) {
	ces, err := sc.CatalogEntries()
	if err != nil {
		return "", err
	}

	for _, ce := range ces {
		if ce.Type == "compute" {
			return ce.Endpoints[0].PublicURL, nil
		}
	}

	return "", fmt.Errorf("Compute endpoint not found.")
}
<commit_msg>Support all regions when listing servers<commit_after>package main

import (
	"fmt"
	"github.com/rackspace/gophercloud/openstack/compute/servers"
	"github.com/rackspace/gophercloud/openstack/identity"
	"github.com/rackspace/gophercloud/openstack/utils"
)

func main() {
	ao, err := utils.AuthOptions()
	if err != nil {
		panic(err)
	}

	a, err := identity.Authenticate(ao)
	if err != nil {
		panic(err)
	}

	sc, err := identity.GetServiceCatalog(a)
	if err != nil {
		panic(err)
	}

	eps, err := findAllComputeEndpoints(sc)
	if err != nil {
		panic(err)
	}

	clients := make([]*servers.Client, len(eps))
	for i, ep := range eps {
		clients[i] = servers.NewClient(ep, a, ao)
	}

	n := 0
	for _, client := range clients {
		listResults, err := servers.List(client)
		if err != nil {
			panic(err)
		}

		svrs, err := servers.GetServers(listResults)
		if err != nil {
			panic(err)
		}

		n = n + len(svrs)

		for _, s := range svrs {
			fmt.Printf("ID(%s)\n", s.Id)
			fmt.Printf("    Name(%s)\n", s.Name)
			fmt.Printf("    IPv4(%s)\n    IPv6(%s)\n", s.AccessIPv4, s.AccessIPv6)
		}
	}
	fmt.Printf("--------\n%d servers listed.\n", n)
}


func findAllComputeEndpoints(sc *identity.ServiceCatalog) ([]string, error) {
	var eps []string

	ces, err := sc.CatalogEntries()
	if err != nil {
		return eps, err
	}

	for _, ce := range ces {
		if ce.Type == "compute" {
			eps := make([]string, len(ce.Endpoints))
			for i, endpoint := range ce.Endpoints {
				eps[i] = endpoint.PublicURL
			}
			return eps, nil
		}
	}

	return eps, fmt.Errorf("Compute endpoint not found.")
}

{'fraction_non_alphanumeric': 0.17225555947758558, 'fraction_numerical': 0.0035298270384751147, 'mean_word_length': 3.3201219512195124, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3213520', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1112, 'n_words': 239}