Skip to content

Officially supported things that get externalized to "null". #400

Open
@dmitshur

Description

@dmitshur

This is a documentation issue/question.

From https://godoc.org/github.com/gopherjs/gopherjs/js, the only mention of things that get externalized to "null" is:

A nil pointer to Object is equal to JavaScript's "null".

$ goexec -quiet -compiler=gopherjs 'js.Global.Get("console").Call("log", (*js.Object)(nil))'
null

However, an (interface{})(nil) also gets externalized to a JavaScript null as far as I can tell:

$ goexec -quiet -compiler=gopherjs 'js.Global.Get("console").Call("log", (interface{})(nil))'
null

Also, in #145 (comment), @dominikh said:

Passing an untyped nil should work, as that gets translated to null.

I'm unsure how to achieve an untyped nil or if it's the same as a nil of type interface{}.

But in either case, I wanted to ask/confirm. Is the fact that (interface{})(nil) gets externalized to a JavaScript null an officially supported feature of GopherJS (that I can/should rely on)?

If so, is it a natural property of Go, or is it a special behavior that should be documented somewhere (since it's currently undocumented as far as I can see)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions