golang.org/x/build@v0.0.0-20240506185731-218518f32b70/maintner/godata/example_test.go (about)

     1  // 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  
     5  package godata_test
     6  
     7  import (
     8  	"context"
     9  	"fmt"
    10  	"log"
    11  
    12  	"golang.org/x/build/maintner"
    13  	"golang.org/x/build/maintner/godata"
    14  )
    15  
    16  func ExampleGet_numComments() {
    17  	corpus, err := godata.Get(context.Background())
    18  	if err != nil {
    19  		log.Fatal(err)
    20  	}
    21  	num := 0
    22  	corpus.GitHub().ForeachRepo(func(gr *maintner.GitHubRepo) error {
    23  		return gr.ForeachIssue(func(gi *maintner.GitHubIssue) error {
    24  			return gi.ForeachComment(func(*maintner.GitHubComment) error {
    25  				num++
    26  				return nil
    27  			})
    28  		})
    29  	})
    30  	fmt.Printf("%d GitHub comments on Go repos.\n", num)
    31  }