Skip to content

Commit

Permalink
Add string for value (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 authored Oct 19, 2022
1 parent 6e18a40 commit 6d2eade
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ygnmi/ygnmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ func (v *Value[T]) IsPresent() bool {
return v.present
}

// String returns a user-readable string for the value.
func (v *Value[T]) String() string {
path, err := ygot.PathToString(v.Path)
if err != nil {
path = v.Path.String()
}
val := "(not present)"
if v.present {
val = fmt.Sprintf("%+v", v.val)
}
return fmt.Sprintf("path: %s\nvalue: %s", path, val)
}

// Client is used to perform gNMI requests.
type Client struct {
gnmiC gpb.GNMIClient
Expand Down

0 comments on commit 6d2eade

Please sign in to comment.