summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/multi-vpp/multi_vpp.go8
-rw-r--r--examples/simple-client/simple_client.go8
-rw-r--r--examples/stats-client/stats_api.go9
-rw-r--r--examples/stream-client/stream_client.go8
4 files changed, 20 insertions, 13 deletions
diff --git a/examples/multi-vpp/multi_vpp.go b/examples/multi-vpp/multi_vpp.go
index c42f802..b207ae4 100644
--- a/examples/multi-vpp/multi_vpp.go
+++ b/examples/multi-vpp/multi_vpp.go
@@ -41,15 +41,15 @@ var (
statsSockAddrVpp2 = flag.String("stats-sock-2", statsclient.DefaultSocketName, "Path to stats socket file of the VPP2")
)
-var Errors []error
+var errors []error
func main() {
flag.Parse()
fmt.Println("Starting multi-vpp example")
defer func() {
- if len(Errors) > 0 {
- logInfo("Finished with %d errors\n", len(Errors))
+ if len(errors) > 0 {
+ logInfo("Finished with %d errors\n", len(errors))
os.Exit(1)
} else {
logInfo("Finished successfully\n")
@@ -347,5 +347,5 @@ func logInfo(format string, a ...interface{}) {
// logError prints error message
func logError(err error, msg string) {
fmt.Printf("[ERROR]: %s: %v\n", msg, err)
- Errors = append(Errors, err)
+ errors = append(errors, err)
}
diff --git a/examples/simple-client/simple_client.go b/examples/simple-client/simple_client.go
index 10a0ea6..3be2447 100644
--- a/examples/simple-client/simple_client.go
+++ b/examples/simple-client/simple_client.go
@@ -74,8 +74,8 @@ func main() {
// process errors encountered during the example
defer func() {
- if len(Errors) > 0 {
- fmt.Printf("finished with %d errors\n", len(Errors))
+ if len(errors) > 0 {
+ fmt.Printf("finished with %d errors\n", len(errors))
os.Exit(1)
} else {
fmt.Println("finished successfully")
@@ -302,9 +302,9 @@ func marshal(v interface{}) {
fmt.Printf("JSON: %s\n", b)
}
-var Errors []error
+var errors []error
func logError(err error, msg string) {
fmt.Printf("ERROR: %s: %v\n", msg, err)
- Errors = append(Errors, err)
+ errors = append(errors, err)
}
diff --git a/examples/stats-client/stats_api.go b/examples/stats-client/stats_api.go
index 288caea..b1846a6 100644
--- a/examples/stats-client/stats_api.go
+++ b/examples/stats-client/stats_api.go
@@ -43,7 +43,7 @@ var (
func init() {
flag.Usage = func() {
- fmt.Fprintf(os.Stderr, "%s: usage [ls|dump|poll|errors|interfaces|nodes|system|buffers] <patterns>...\n", os.Args[0])
+ fmt.Fprintf(os.Stderr, "%s: usage [ls|dump|poll|errors|interfaces|nodes|system|buffers|memory] <patterns>...\n", os.Args[0])
flag.PrintDefaults()
os.Exit(1)
}
@@ -129,6 +129,13 @@ func main() {
}
fmt.Printf("Buffer stats: %+v\n", stats)
+ case "memory":
+ stats := new(api.MemoryStats)
+ if err := c.GetMemoryStats(stats); err != nil {
+ log.Fatalln("getting memory stats failed:", err)
+ }
+ fmt.Printf("Memory stats: %+v\n", stats)
+
case "dump":
fmt.Printf("Dumping stats.. %s\n", strings.Join(patterns, " "))
diff --git a/examples/stream-client/stream_client.go b/examples/stream-client/stream_client.go
index fadfe23..f4af859 100644
--- a/examples/stream-client/stream_client.go
+++ b/examples/stream-client/stream_client.go
@@ -76,8 +76,8 @@ func main() {
// process errors encountered during the example
defer func() {
- if len(Errors) > 0 {
- fmt.Printf("finished with %d errors\n", len(Errors))
+ if len(errors) > 0 {
+ fmt.Printf("finished with %d errors\n", len(errors))
os.Exit(1)
} else {
fmt.Println("finished successfully")
@@ -294,9 +294,9 @@ Loop:
fmt.Println()
}
-var Errors []error
+var errors []error
func logError(err error, msg string) {
fmt.Printf("ERROR: %s: %v\n", msg, err)
- Errors = append(Errors, err)
+ errors = append(errors, err)
}