MCPcopy Create free account
hub / github.com/DoNewsCode/core / Example

Function Example

otetcd/example_test.go:14–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12)
13
14func Example() {
15 if os.Getenv("ETCD_ADDR") == "" {
16 fmt.Println("set ETCD_ADDR to run example")
17 return
18 }
19 c := core.New()
20 c.ProvideEssentials()
21 c.Provide(otetcd.Providers())
22 c.Invoke(func(cli *clientv3.Client) {
23 _, err := cli.Put(context.TODO(), "foo", "bar")
24 if err != nil {
25 log.Fatal("etcd put failed")
26 }
27 resp, _ := cli.Get(context.TODO(), "foo")
28 for _, ev := range resp.Kvs {
29 fmt.Printf("%s : %s\n", ev.Key, ev.Value)
30 }
31 })
32 // Output:
33 // foo : bar
34}

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
ProvidersFunction · 0.92
ProvideEssentialsMethod · 0.80
ProvideMethod · 0.80
InvokeMethod · 0.80
GetMethod · 0.65
PrintfMethod · 0.45

Tested by

no test coverage detected