Skip to content

Ability to change go vars (both JS primitives and JS Object) after they are #Set'ed to Js.Object #79

Closed
@truongsinh

Description

@truongsinh
package main

import (
    "github.com/gopherjs/gopherjs/js"
)

func main() {
    var MyStringValue string

    MyStringValue = "MyStringValue1"
    js.Global.Set("MyStringValue", MyStringValue)
    println(js.Global.Get("MyStringValue")) // passed - MyStringValue1

    MyStringValue = "MyStringValue2"
    println(js.Global.Get("MyStringValue")) // passed - MyStringValue1

    MyStringPointer := &MyStringValue
    *MyStringPointer = "MyStringValue3"
    println(js.Global.Get("MyStringValue")) // failed - expected MyStringValue3, got MyStringValue1

    *MyStringPointer = "MyStringValue4"
    js.Global.Set("MyStringValue", MyStringPointer)
    println(js.Global.Get("MyStringValue")) // failed - expected MyStringValue4, got Object{}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions