5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 06:01:52 +08:00

Handle use cases where the function is not from main (#655)

* Handle use cases where the function is not from main
This commit is contained in:
Sithembiso Khumalo 2021-05-16 06:08:30 +02:00 committed by GitHub
parent f6d0d383f1
commit 5302ce57db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"runtime" "runtime"
"strings"
"github.com/wailsapp/wails/lib/logger" "github.com/wailsapp/wails/lib/logger"
) )
@ -27,6 +28,10 @@ func newBoundFunction(object interface{}) (*boundFunction, error) {
objectType := reflect.TypeOf(object) objectType := reflect.TypeOf(object)
name := runtime.FuncForPC(objectValue.Pointer()).Name() name := runtime.FuncForPC(objectValue.Pointer()).Name()
if strings.Contains(name, "/") {
parts := strings.Split(name, "/")
name = parts[len(parts)-1]
}
result := &boundFunction{ result := &boundFunction{
fullName: name, fullName: name,