I've started learning GO, and i have encountered this issue. I have this code
package main
import (
"fmt"
"encoding/json"
// "net/html"
)
func main(){
type Weather struct {
name string
cod float64
dt float64
id float64
}
var rawWeather = []byte(`{"name":"London","cod":200,"dt":1407100800,"id":2643743}`)
var w Weather
err := json.Unmarshal(rawWeather, &w)
if err != nil {
fmt.Println("Some error", err)
}
fmt.Printf("%+v
",w)
}
when i run it, it shows this
[nap@rhel projects]$ go run euler.go
{name: cod:0 dt:0 id:0}
So, the JSON is not parsed into the weather struct.
Any ideas, why do this happens like this?