forked from falcosecurity/client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (33 loc) · 854 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"context"
"fmt"
"log"
"github.com/falcosecurity/client-go/pkg/api/version"
"github.com/falcosecurity/client-go/pkg/client"
"github.com/gogo/protobuf/jsonpb"
)
func main() {
// Set up a connection to the server.
c, err := client.NewForConfig(context.Background(), &client.Config{
UnixSocketPath: "unix:///var/run/falco.sock",
})
if err != nil {
log.Fatalf("unable to create a Falco client: %v", err)
}
defer c.Close()
versionClient, err := c.Version()
if err != nil {
log.Fatalf("unable to obtain a version client: %v", err)
}
ctx := context.Background()
res, err := versionClient.Version(ctx, &version.Request{})
if err != nil {
log.Fatalf("error obtaining the Falco version: %v", err)
}
out, err := (&jsonpb.Marshaler{}).MarshalToString(res)
if err != nil {
log.Fatal(err)
}
fmt.Println(out)
}