blob: a5351b5c79e78f1f33b66004c06c3a3f4f68bffb [file] [log] [blame]
Kevin Burke3f648ee2017-12-15 14:30:21 -08001// Copyright 2017 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package maintner_test
6
7import (
8 "context"
9 "fmt"
10 "log"
11 "os"
12 "path/filepath"
13
14 "golang.org/x/build/maintner"
15)
16
17func Example() {
18 cacheDir := filepath.Join(os.Getenv("HOME"), "var", "maintnerd")
19 // maintner.golang.org contains the metadata for the Go project and related
20 // Github repositories and issues.
21 mutSrc := maintner.NewNetworkMutationSource("https://maintner.golang.org/logs", cacheDir)
22 corpus := new(maintner.Corpus)
23 if err := corpus.Initialize(context.Background(), mutSrc); err != nil {
24 log.Fatal(err)
25 }
26 err := corpus.GitHub().ForeachRepo(func(r *maintner.GitHubRepo) error {
27 fmt.Println(r.ID())
28 return nil
29 })
30 if err != nil {
31 log.Fatal(err)
32 }
33}
34
35func Example_fromDisk() {
36 logger := maintner.NewDiskMutationLogger(filepath.Join(os.Getenv("HOME"), "var", "maintnerd"))
37 corpus := new(maintner.Corpus)
38 corpus.Initialize(context.Background(), logger)
39 err := corpus.GitHub().ForeachRepo(func(r *maintner.GitHubRepo) error {
40 fmt.Println(r.ID())
41 return nil
42 })
43 if err != nil {
44 log.Fatal(err)
45 }
46}
47
48func ExampleDiskMutationLogger() {
49 logger := maintner.NewDiskMutationLogger(filepath.Join(os.Getenv("HOME"), "var", "maintnerd"))
50 corpus := new(maintner.Corpus)
51 corpus.Initialize(context.Background(), logger)
52 err := corpus.GitHub().ForeachRepo(func(r *maintner.GitHubRepo) error {
53 fmt.Println(r.ID())
54 return nil
55 })
56 if err != nil {
57 log.Fatal(err)
58 }
59}