I'm use go & go-qml on Archlinux with qt5 installed.
I got the error message when I execute 'ex3' (It compiles OK).
$ ./ex3
display 0x854dd60
panic: file:////home/dlin/prj/qml/ex3/ex3.qml.:2 module "GoExtensions" is not installed
goroutine 1 [running, locked to thread]:
main.main()
/home/dlin/prj/qml/ex3/ex3.go:8 +0x5b
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/lib/go/src/runtime/asm_386.s:2287 +0x1
ex3.qml
------------
import QtQuick 2.0
import GoExtensions 1.0
Item{
Person {
id: person
name: "Daniel"
}
Component.onCompleted: console.log("Name is",
person.name)
}
ex3.go
----------
package main
import "
gopkg.in/qml.v1"
func main() {
err := qml.Run(run)
if err != nil {
panic(err)
}
}
type Person struct {
Name string
}
func run() error {
engine := qml.NewEngine()
component, err := engine.LoadFile("ex3.qml")
if err != nil {
return err
}
// Publishing Go types to QML
qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
Init: func(p *Person, obj qml.Object) { p.Name = "<none>" },
}})
win := component.CreateWindow(nil)
win.Show()
win.Wait()
return nil
}