main
 1package gitlab
 2
 3import (
 4	"fmt"
 5
 6	"github.com/xlgmokha/x/pkg/x"
 7)
 8
 9type Group struct {
10	api *GitLab
11	id  int
12	url string
13}
14
15func NewGroup(gl *GitLab, id int) *Group {
16	return &Group{
17		api: gl,
18		id:  id,
19		url: fmt.Sprintf("%v/groups/%v", gl.url, id),
20	}
21}
22
23func (group *Group) EachIssue(fn func(*Issue)) {
24	page := "1"
25	perPage := "100"
26	for page != "" {
27		response := group.api.Get(fmt.Sprintf("%v/issues?page=%v&per_page=%v", group.url, page, perPage))
28		defer response.Body.Close()
29
30		for _, issue := range x.Must(FromIssues(response.Body)) {
31			go fn(&issue)
32		}
33
34		page = response.Header.Get("x-next-page")
35		perPage = response.Header.Get("x-per-page")
36	}
37}