Skip to content

Commit 30fbb43

Browse files
committed
docs: add e2e example
1 parent b607904 commit 30fbb43

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

client_example_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package paperswithcode_go_test
2+
3+
import (
4+
"fmt"
5+
6+
paperswithcode_go "github.com/codingpot/paperswithcode-go"
7+
)
8+
9+
func Example() {
10+
c := paperswithcode_go.NewClient()
11+
papers, _ := c.PaperList(paperswithcode_go.PaperListParamsDefault())
12+
fmt.Println(len(papers.Results))
13+
14+
gan, _ := c.PaperGet(paperswithcode_go.GetPaperIDFromPaperTitle("Generative Adversarial Networks"))
15+
fmt.Println(gan.Title)
16+
fmt.Println(gan.Authors)
17+
18+
// Output:
19+
// 50
20+
// Generative Adversarial Networks
21+
// [Ian J. Goodfellow Jean Pouget-Abadie Mehdi Mirza Bing Xu David Warde-Farley Sherjil Ozair Aaron Courville Yoshua Bengio]
22+
}

models/paper_list_result.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package models
22

3+
import "fmt"
4+
35
// PaperListResult is the result of PaperListResult() function.
46
type PaperListResult struct {
57
Count int64 `json:"count"`
@@ -8,6 +10,8 @@ type PaperListResult struct {
810
Results []PaperListResultItem `json:"results"`
911
}
1012

13+
var _ fmt.Stringer = (*PaperListResultItem)(nil)
14+
1115
type PaperListResultItem struct {
1216
ID string `json:"id"`
1317
ArxivID *string `json:"arxiv_id"`
@@ -23,3 +27,8 @@ type PaperListResultItem struct {
2327
ConferenceURLPDF *string `json:"conference_url_pdf"`
2428
Proceeding *string `json:"proceeding"`
2529
}
30+
31+
func (p PaperListResultItem) String() string {
32+
return fmt.Sprintf("ID: %s ArxivID: %v NipsID: %v, URLAbs: %s, URLPDF: %s Title: %s Authors: %s",
33+
p.ID, p.ArxivID, p.NipsID, p.URLAbs, p.URLPDF, p.Title, p.Authors)
34+
}

0 commit comments

Comments
 (0)