twitch: code-style: define structure at the top - twitch-go - twitch.tv web application in Go
(HTM) git clone git://git.codemadness.org/twitch-go
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 311de01e329f82c99ea58ace5498a03f1725c6db
(DIR) parent ca6c9cadb7d7eb739ab02a5c88229968ab5e0ecb
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 6 Apr 2019 20:05:07 +0200
twitch: code-style: define structure at the top
Diffstat:
M src/twitch/twitch.go | 42 ++++++++++++++++----------------
1 file changed, 21 insertions(+), 21 deletions(-)
---
(DIR) diff --git a/src/twitch/twitch.go b/src/twitch/twitch.go
@@ -119,6 +119,27 @@ type Users struct {
Items []User `json:"data"`
}
+type Video struct {
+ Created_at string `json:"created_at"`
+ Description string `json:"description"`
+ Duration string `json:"duration"`
+ Id string `json:"id"`
+ Language string `json:"language"`
+ Published_at string `json:"published_at"`
+ Thumbnail_url string `json:"thumbnail_url"`
+ Title string `json:"title"`
+ Type string `json:"type"`
+ Url string `json:"url"`
+ User_id string `json:"user_id"`
+ User_name string `json:"user_name"`
+ View_count int64 `json:"view_count"`
+ Viewable string `json:"viewable"`
+}
+
+type Videos struct {
+ Items []Video `json:"data"`
+}
+
func ReadAllUrl(url string) ([]byte, error) {
client := http.Client{
Timeout: time.Duration(30) * time.Second,
@@ -202,27 +223,6 @@ func GetGame(game string) (*Game, error) {
return &v, nil
}
-type Video struct {
- Created_at string `json:"created_at"`
- Description string `json:"description"`
- Duration string `json:"duration"`
- Id string `json:"id"`
- Language string `json:"language"`
- Published_at string `json:"published_at"`
- Thumbnail_url string `json:"thumbnail_url"`
- Title string `json:"title"`
- Type string `json:"type"`
- Url string `json:"url"`
- User_id string `json:"user_id"`
- User_name string `json:"user_name"`
- View_count int64 `json:"view_count"`
- Viewable string `json:"viewable"`
-}
-
-type Videos struct {
- Items []Video `json:"data"`
-}
-
func GetVideosByGame(gameid string) (*Videos, error) {
s := fmt.Sprintf("https://api.twitch.tv/helix/videos?first=100&game_id=%s", url.QueryEscape(gameid))
body, err := ReadAllUrl(s)