Skip to content

Instantly share code, notes, and snippets.

@StephanieSunshine
Created May 18, 2023 04:48
Show Gist options
  • Save StephanieSunshine/17cb94bdb20acd2b44d762681c80f93a to your computer and use it in GitHub Desktop.
Save StephanieSunshine/17cb94bdb20acd2b44d762681c80f93a to your computer and use it in GitHub Desktop.
Golang Reflect Help Wanted -- How do I dereference this reflect.Value?
Output without trying to call the Function:
1
F1_Init
F1 Comming Online
(SerenadeMi.Entry) {
FnNum: (uint) 1,
FnName: (string) (len=5) "hello",
SDesc: (string) (len=11) "Print Hello",
Ldesc: (string) (len=16) "Test Print Hello",
Fn: (func(*interface {}) error) 0x1024b3e30
}
Output with trying to call the Function:
../../../go/pkg/mod/github.com/!b!bs!mi/!serenade!mi@v0.0.0-20230518043455-70679cc3eeda/functions.go:23:9: res.Fn undefined (type any has no field or method Fn)
module newapp
go 1.19
require github.com/BBsMi/SerenadeMi v0.0.0-20230518042544-972f9953932e
require github.com/davecgh/go-spew v1.1.1 // indirect
import (
// "fmt"
// "reflect"
smi "newapp/menu"
"github.com/BBsMi/SerenadeMi"
)
func main() {
// fmt.Println("Hello")
// smi.F1(nil)
i := smi.Inits{}
SerenadeMi.Init(&i)
}
package SerenadeMiFunctions
import (
"fmt"
"github.com/BBsMi/SerenadeMi"
)
func (i *Inits) F1_Init() SerenadeMi.Entry {
fmt.Println("F1 Comming Online")
return SerenadeMi.Entry{1, "hello", "Print Hello", "Test Print Hello", F1}
}
func F1(attrib *interface{}) error {
fmt.Println("F1 Running")
return nil
}
package SerenadeMiFunctions
import "github.com/BBsMi/SerenadeMi"
type Inits SerenadeMi.Inits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment