-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathhello-wttr.go
40 lines (32 loc) · 890 Bytes
/
hello-wttr.go
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
33
34
35
36
37
38
39
40
// Copyright 2020 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/chai2010/pbgo"
)
func main() {
var reply struct {
CurrentCondition []struct {
FeelsLikeC string `json:"FeelsLikeC"`
FeelsLikeF string `json:"FeelsLikeF"`
Cloudcover string `json:"cloudcover"`
Humidity string `json:"humidity"`
LocalObsDateTime string `json:"localObsDateTime"`
Observation_time string `json:"observation_time"`
} `json:"current_condition"`
}
err := pbgo.HttpGet("http://wttr.in/wuhan?format=j1", nil, &reply)
if err != nil {
log.Fatal(err)
}
json, err := json.MarshalIndent(reply, "", " ")
if err != nil {
log.Fatal(err)
}
fmt.Println(string(json))
}