Skip to content

Commit

Permalink
Fix various nits. #2
Browse files Browse the repository at this point in the history
  • Loading branch information
ostromart committed Oct 20, 2017
1 parent 2b1d2fa commit 0f95eb8
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions demo/getting_started/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"

oc "github.com/openconfig/ygot/demo/getting_started/pkg/ocdemo"
"github.com/openconfig/ygot/util"
"github.com/openconfig/ygot/ygot"
)

Expand Down Expand Up @@ -116,12 +115,10 @@ func main() {
}
ygot.BuildEmptyTree(subif)
_, err = subif.Ipv4.NewAddress("Not a valid address")
if errs := invalidIf.Validate(); errs == nil {
panic(fmt.Sprintf("Did not find invalid address, got nil err: %v", errs))
if err := invalidIf.Validate(); err == nil {
panic(fmt.Sprintf("Did not find invalid address, got nil err: %v", err))
} else {
for _, e := range errs {
fmt.Printf("Got expected error: %v\n", e)
}
fmt.Printf("Got expected error: %v\n", err)
}

// We can also validate the device overall.
Expand All @@ -143,10 +140,10 @@ func main() {
}
fmt.Println(json)

// The generated code includes an Unmarshal function, which can be used to load
// a data tree such as the one that we just created.
loadd := &oc.Device{}
if err := oc.Unmarshal([]byte(json), loadd); err != nil {
panic(fmt.Sprintf("Can't unmarshal JSON: %v", err))
}
// The generated code includes an Unmarshal function, which can be used to load
// a data tree such as the one that we just created.
loadd := &oc.Device{}
if err := oc.Unmarshal([]byte(json), loadd); err != nil {
panic(fmt.Sprintf("Can't unmarshal JSON: %v", err))
}
}

0 comments on commit 0f95eb8

Please sign in to comment.