https://github.com/digitalocean/go-metadata
Go client for the metadata API.
https://github.com/digitalocean/go-metadata
Last synced: 3 months ago
JSON representation
Go client for the metadata API.
- Host: GitHub
- URL: https://github.com/digitalocean/go-metadata
- Owner: digitalocean
- License: mit
- Created: 2015-09-17T15:30:08.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2025-01-29T10:03:19.000Z (over 1 year ago)
- Last Synced: 2025-01-29T11:20:03.011Z (over 1 year ago)
- Language: Go
- Size: 18.6 KB
- Stars: 27
- Watchers: 175
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# metadata [](https://godoc.org/github.com/digitalocean/go-metadata)
A Go client to interact with the [DigitalOcean Metadata API](https://developers.digitalocean.com/documentation/metadata/).
# Usage
```go
// Create a client
client := metadata.NewClient(opts)
// Request all the metadata about the current droplet
all, err := client.Metadata()
if err != nil {
log.Fatal(err)
}
// Lookup what our IPv4 address is on our first public
// network interface.
publicIPv4Addr := all.Interfaces["public"][0].IPv4.IPAddress
fmt.Println(publicIPv4Addr)
```
# License
MIT license