File tree 1 file changed +15
-8
lines changed
1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ type item struct {
15
15
Key string `json:"key,omitempty"`
16
16
Name string `json:"name,omitempty"`
17
17
Caption string `json:"caption,omitempty"`
18
+ Authors []struct {
19
+ ID string `json:"id"`
20
+ Active bool `json:"active"`
21
+ } `json:"authors,omitempty"`
22
+ Topics []string `json:"topics,omitempty"`
18
23
}
19
24
20
25
func main () {
@@ -33,31 +38,33 @@ func main() {
33
38
log .Fatal (err )
34
39
}
35
40
36
- for _ , pkg := range list {
37
- valStream <- pkg
41
+ for _ , o := range list {
42
+ valStream <- o
38
43
}
39
44
}()
40
45
return valStream
41
46
}
42
47
43
- doWork := func (o item ) string {
48
+ doWork := func (o item ) item {
44
49
resp , err := http .Get ("https://ctan.org/json/2.0/pkg/" + o .Key )
45
50
if err != nil {
46
51
log .Fatal (err )
47
52
}
48
53
defer resp .Body .Close ()
49
54
50
- var pkg item
51
- if err = json .NewDecoder (resp .Body ).Decode (& pkg ); err != nil {
52
- log .Fatal (pkg .ID , err )
55
+ if err = json .NewDecoder (resp .Body ).Decode (& o ); err != nil {
56
+ log .Fatal (o .ID , err )
53
57
}
54
- return pkg . ID
58
+ return o
55
59
}
56
60
57
61
ctx , cancel := context .WithCancel (context .TODO ())
58
62
defer cancel ()
59
63
60
64
for s := range oproc .OrderedProc (ctx , inputStream (), doWork , 20 ) {
61
- fmt .Println (s )
65
+ b , err := json .Marshal (s )
66
+ if err == nil {
67
+ fmt .Println (string (b ))
68
+ }
62
69
}
63
70
}
You can’t perform that action at this time.
0 commit comments