Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
api
✓ github.com/hashicorp/consul/api
Create a Consul client and retrieve agent self information.
package main
import (
"fmt"
"github.com/hashicorp/consul/api"
)
func main() {
client, err := api.NewClient(api.DefaultConfig())
if err != nil {
panic(err)
}
agent := client.Agent()
self, err := agent.Self()
if err != nil {
panic(err)
}
fmt.Println(self["Config"]["NodeName"])
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
1.34.3latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.