Skip to content

Exported methods from embedded structs #548

Open
@bcspragu

Description

@bcspragu

When calling MakeWrapper on a struct containing embedded structs, only methods on the top-level struct are exposed in the resulting js.Object

Example

package main

import (
	"fmt"

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

func main() {
	js.Global.Set("Example", map[string]interface{}{
		"New": New,
	})
}

type A struct{}

func (a A) MethodA() {
	fmt.Println("A")
}

type B struct {
	A
}

func (b B) MethodB() {
	fmt.Println("B")
}

func New() *js.Object {
	return js.MakeWrapper(B{A{}})
}

Playground link

In Go, it'd be fine to call B{A{}}}.MethodA(), but the resulting js.Object only has MethodB.

I did some searching around, but couldn't find any other issues/references to why this is the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions