Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
c5f12546
Unverified
Commit
c5f12546
authored
Sep 24, 2018
by
Sander van Harmelen
Committed by
GitHub
Sep 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the pagination example (#475)
parent
8d21e61c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
pagination.go
examples/pagination.go
+18
-6
No files found.
examples/pagination.go
View file @
c5f12546
...
...
@@ -2,6 +2,7 @@ package main
import
(
"fmt"
"log"
"github.com/xanzy/go-gitlab"
)
...
...
@@ -16,13 +17,24 @@ func pagination() {
},
}
_
,
resp
,
_
:=
git
.
Projects
.
ListProjects
(
opt
)
// Page 1
for
page
:=
2
;
page
<
resp
.
TotalPages
;
page
++
{
opt
.
ListOptions
.
Page
=
page
projects
,
_
,
_
:=
git
.
Projects
.
ListProjects
(
opt
)
for
{
// Get the first page with projects.
ps
,
resp
,
err
:=
git
.
Projects
.
ListProjects
(
opt
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
// List all the projects we've found so far.
for
_
,
p
:=
range
ps
{
fmt
.
Printf
(
"Found project: %s"
,
p
.
Name
)
}
for
_
,
p
:=
range
projects
{
fmt
.
Println
(
p
.
ID
)
// Exit the loop when we've seen all pages.
if
opt
.
Page
>=
resp
.
TotalPages
{
break
}
// Update the page number to get the next page.
opt
.
Page
=
resp
.
NextPage
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment