Code Review
/
ric-plt
/
sdlgo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Move SDL usage code example
[ric-plt/sdlgo.git]
/
example
/
example.go
diff --git
a/example_test.go
b/example/example.go
similarity index 68%
rename from
example_test.go
rename to
example/example.go
index
d3be2f7
..
aee1c19
100644
(file)
--- a/
example_test.go
+++ b/
example/example.go
@@
-1,6
+1,6
@@
/*
Copyright (c) 2019 AT&T Intellectual Property.
/*
Copyright (c) 2019 AT&T Intellectual Property.
- Copyright (c) 2018-20
19
Nokia.
+ Copyright (c) 2018-20
22
Nokia.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@
-20,7
+20,7
@@
* platform project (RICP).
*/
* platform project (RICP).
*/
-package
sdlgo_test
+package
main
import (
"fmt"
import (
"fmt"
@@
-34,21
+34,33
@@
func init() {
sdl = sdlgo.NewSyncStorage()
}
sdl = sdlgo.NewSyncStorage()
}
-func
ExampleSdlInstance_
Set() {
- err := sdl.Set("
namespace", "stringdata", "data", "
intdata", 42)
+func
example
Set() {
+ err := sdl.Set("
my-namespace", "somestringdata", "data", "some
intdata", 42)
if err != nil {
panic(err)
} else {
fmt.Println("Data written successfully")
}
if err != nil {
panic(err)
} else {
fmt.Println("Data written successfully")
}
- // Output: Data written successfully
}
}
-func
ExampleSdlInstance_
Get() {
- retMap, err := sdl.Get("
namespace", []string{"stringdata", "
intdata"})
+func
example
Get() {
+ retMap, err := sdl.Get("
my-namespace", []string{"somestringdata", "some
intdata"})
if err != nil {
panic(err)
} else {
if err != nil {
panic(err)
} else {
- fmt.Println(retMap)
+ fmt.Println("Data read successfully")
+ for k, v := range retMap {
+ fmt.Println("\t", k, "key value is", v)
+ }
}
}
}
}
+
+func exampleClose() {
+ sdl.Close()
+}
+
+func main() {
+ exampleSet()
+ exampleGet()
+ exampleClose()
+}