What's wrong with the first one?
The second one doesn't work because there are not interface composite
literals. So you need to actually have an interface{} variable to take the
address of.
The third one seems to work just fine: https://play.golang.org/p/zn2mL69VzPo

On Thu, Sep 3, 2020 at 10:32 PM Alexander Mills <alexander.d.mi...@gmail.com>
wrote:

> This works:
>
> var z interface{}
> if err := json.NewDecoder(resp.Body).Decode(&z); err != nil {
>      t.Fatal(err)
> }
>
> but this doesn't work:
>
> if err := json.NewDecoder(resp.Body).Decode(&interface{}{}); err != nil {
>      t.Fatal(err)
> }
>
> and this doesn't work:
>
> if err := json.NewDecoder(resp.Body).Decode(&struct{}{}); err != nil {
>      t.Fatal(err)
> }
>
>
> my goal is to unmarshal to an anonymous variable and discard it, as part
> of a test. Is there a way to do this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/8f58f470-8055-49bc-a248-92a496473f8bn%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/8f58f470-8055-49bc-a248-92a496473f8bn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfHrVdqn87qWHuxWnyBD%3Dn8y0qr8WcQdjH6RG5zcv-OAtA%40mail.gmail.com.

Reply via email to