-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
This makes sense given the way that go2go
works, but it should probably at least give a clearer error message that explains that the tool doesn't support that.
package main
import (
"encoding/json"
"fmt"
"io"
"strings"
)
func Decode(type T)(r io.Reader) (T, error) {
var t T
err := json.NewDecoder(r).Decode(&t)
return t, err
}
func main() {
type s struct {
This string `json:"this"`
A string `json:"a"`
}
t, err := Decode(s)(strings.NewReader(`{"this": "is", "a": "test"}`))
if err != nil {
panic(err)
}
fmt.Printf("%#v", t)
}
Output:
# play
./prog.go2:22: undefined: s
./prog.go2:11: undefined: s