-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkshop.go
More file actions
32 lines (28 loc) · 884 Bytes
/
workshop.go
File metadata and controls
32 lines (28 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"encoding/json"
"fmt"
)
// Workshop is a type.
type Workshop struct {
Name string `json:"name"`
Description string `json:"description"`
Logo string `json:"preview_url"`
Level int `json:"level"`
}
// GetWorkshopInfo is a function that can get the infomation of a workshop.
func GetWorkshopInfo(id string) Workshop {
pageBytes := Scrap("https://api.codemao.cn/web/shops/" + string(id))
var workshop Workshop
json.Unmarshal(pageBytes, &workshop)
return workshop
}
// NotifyWorkshopInfo can print the info.
func NotifyWorkshopInfo(w Workshop) {
fmt.Printf("Name:\t%s\n", w.Name)
fmt.Println("Description: --------------------------------------")
fmt.Printf("%s\n", w.Description)
fmt.Println("---------------------------------------------------")
fmt.Printf("Logo URL:\t%s\n", w.Logo)
fmt.Printf("Level:\t%d\n", w.Level)
}