Closed
Description
- Create the following three files.
- Run
gopherjs serve
and loadalltom/
in your browser. - Edit iface.go to change
Bar() int
toBar2() int
. - Edit main.go to change
impl.MakeFoo().Bar()
toimpl.MakeFoo().Bar2()
. - Reload your browser.
Instead of seeing a compile error about FooImpl no longer implementing Foo, you get a runtime error saying "Uncaught TypeError: impl.MakeFoo(...).Bar2 is not a function". It looks like gopherjs serve
doesn't realize that impl.go needs to be recompiled.
alltom/iface/iface.go
package iface
type Foo interface {
Bar() int
}
alltom/impl/impl.go
package impl
import "alltom/iface"
type FooImpl int
func MakeFoo() iface.Foo {
return FooImpl(0)
}
func (f FooImpl) Bar() int {
return 42
}
alltom/main.go
package main
import "alltom/impl"
func main() {
impl.MakeFoo().Bar()
}