-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathexample_test.go
59 lines (53 loc) · 1.52 KB
/
example_test.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package maintner_test
import (
"context"
"fmt"
"log"
"os"
"path/filepath"
"golang.org/x/build/maintner"
)
func Example() {
cacheDir := filepath.Join(os.Getenv("HOME"), "var", "maintnerd")
// maintner.golang.org contains the metadata for the Go project and related
// Github repositories and issues.
mutSrc := maintner.NewNetworkMutationSource("https://maintner.golang.org/logs", cacheDir)
corpus := new(maintner.Corpus)
if err := corpus.Initialize(context.Background(), mutSrc); err != nil {
log.Fatal(err)
}
err := corpus.GitHub().ForeachRepo(func(r *maintner.GitHubRepo) error {
fmt.Println(r.ID())
return nil
})
if err != nil {
log.Fatal(err)
}
}
func Example_fromDisk() {
logger := maintner.NewDiskMutationLogger(filepath.Join(os.Getenv("HOME"), "var", "maintnerd"))
corpus := new(maintner.Corpus)
corpus.Initialize(context.Background(), logger)
err := corpus.GitHub().ForeachRepo(func(r *maintner.GitHubRepo) error {
fmt.Println(r.ID())
return nil
})
if err != nil {
log.Fatal(err)
}
}
func ExampleDiskMutationLogger() {
logger := maintner.NewDiskMutationLogger(filepath.Join(os.Getenv("HOME"), "var", "maintnerd"))
corpus := new(maintner.Corpus)
corpus.Initialize(context.Background(), logger)
err := corpus.GitHub().ForeachRepo(func(r *maintner.GitHubRepo) error {
fmt.Println(r.ID())
return nil
})
if err != nil {
log.Fatal(err)
}
}