aboutsummaryrefslogtreecommitdiff
path: root/client/cmd/get-sth/main.go
blob: 6b23b060dc0ff03604c2e73088fe5f5fda8644a1 (plain)
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
package main

import (
	"context"
	"flag"
	"fmt"

	"encoding/base64"

	"github.com/golang/glog"
	"github.com/system-transparency/stfe/client"
	"github.com/system-transparency/stfe/types"
)

func main() {
	flag.Parse()
	defer glog.Flush()

	client, err := client.NewClientFromFlags()
	if err != nil {
		glog.Errorf("NewClientFromFlags: %v", err)
		return
	}
	sth, err := client.GetLatestSth(context.Background())
	if err != nil {
		glog.Errorf("GetLatestSth: %v", err)
		return
	}
	serialized, err := types.Marshal(*sth)
	if err != nil {
		glog.Errorf("Marshal: %v", err)
		return
	}
	fmt.Println("sth:", base64.StdEncoding.EncodeToString(serialized))
}