Eureka client for Go projects for fetching all registered application in Eureka or fetching any available instance IP by application's name.
go get github.com/oneils/go-eureka-client
Create Eureka client by specifying http client and Eureka server's URL.
client := http.Client{Timeout: 1 * time.Second}
c := eureka.NewClient(&client, eurekaServer.URL+"/eureka/apps")
import (
"github.com/oneils/go-eureka-client/pkg/eureka"
)
apps, err := c.FetchAll()
if err != nil {
log.Fatal(err)
}
for _, app := range apps {
fmt.Println(app.Name)
}
app, err := c.FetchIPAddress("my-app")
if err != nil {
log.Fatal(err)
}
fmt.Println(app.IPAddr)