I`m new in Golang and have a problem with calling a package function/s by
string name from another package.
i read a lot of this topic and still can`t find a solution for my problem :(
This is the first time i write anything on the web forums ever so please
excuse me for the noob writing.
I will try to give you as much info as possible for my problem so ..
I'm trying to build web base small framework with dynamic struct of data
looking like this :
1.Framework core functions location is : ../src/core/myStruct
*package myStruct { type MFunc map[string]func(); type MapStr
map[string]string; .... type TableRec struct { TABLE_OPTIONS
TableData; // table options from JSON file FIELDS MapData;
// fields from JSON file ..... METHODS MapStr; //
METHODS MFunc; // MFunc get a error :`( =>( EXTRA
*json.SyntaxError=invalid character 'F' looking for beginning of value) }}*
2.load JSON from System1 location : ../src/sys/System1/tables
Json file ..:
*{ "TABLE_OPTIONS" : { "TABLE_NAME": "FORM_INS",
"SYSTEM_ON" : "System1", ........... }, "METHODS" : {
//"on_insert" : Form_ins_insert // error from MFunc
"on_insert" : "Form_ins_insert" //MapStr work :/ ......
}, "FIELDS" : { "ID" : { "TYPE" : "INT",
"VALUE" : 0, "OPTIONS": { "RO": 1 , "HID": 0 } },
"NAME" : { "SEP": { "en" : "Person Data" , "bg" :
"Данни за клинета" }, "LABEL": { "en" : "Full name","bg" :
"Пълно име" }, "TYPE": "CHAR", "VALUE": "",
"SIZE" : 200, "OPTIONS": {"ROW": 2 , "ROW_SIZE": 100 }
}, ...... } .....}*
3 Must call func from System1 (or System2, or System3 ...) and send it the
struct with the data i push in the struct in the core
location : ../src/sys/System1/methods
*package methodsimport ( "fmt" _ "../core/myStruct" )func
Form_ins_insert(rec *TableRec) (html string) {
fmt.Println("================== Form_ins_insert ================");
fmt.Println("\t\t on table =",rec.TABLE_OPTIONS.TABLE_NAME); // i must
get to this point but have 0 ideas how :`( ..... return html; }*
*4 !!!! THE PROBLEM PART !!!!!*
And the "callerFunc" (the relay station) calling System1,..,SystemN
location : ../src/sys
*package sysimport ( "fmt" "../core/myStruct" _
"../sys/System1/methods" _ "../sys/System2/methods" // i thing i must
set all systems here 1 by one ...)func CallSysMeth(rec *myStruct.TableRec,
name string) { myRec := rec; fmt.Println("==================
CallSysMeth ================"); fmt.Println("======method name to call
=",name," , Struct=",myRec.METHODS); // THIS PART IS LOST IN TRANSLATION
FOR ME ?!?!?!?!?!?!?!?!?!?!?!?! // how to call system1 from
"rec.TABLE_OPTIONS.SYSTEM_ON" with method name "Form_ins_insert" and send
it the struct ???? ......}*
*I`m open for any ideas what ever how to make it work but how to make it
better.Keep in mind that every "table" can have a different methods and any
"system" can have this methods and tables so i must call system from the
"rec.TABLE_OPTIONS.SYSTEM_ON" with the method from "METHODS" list.I decide
to make it in JSON objects for flexibility so small changes like changing
the labels (translating ) ор OPTIONS can be made without server restarts
compiles and so on.*
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.