Documentation ¶
Overview ¶
Package gogtm enables access to gt.m database
Index ¶
- func Data(global string) (value, descendent bool, err error)
- func Get(global string, opt string) (string, error)
- func GvStat() (string, error)
- func Kill(global string) error
- func Order(global string, dir string) (string, error)
- func Query(global string) (string, error)
- func Set(global string, val string) error
- func Start() error
- func Stop() error
- func Xecute(code string) error
- func ZKill(global string) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Data ¶
Data returns 2 boolean values describing the value and descendent status of a local or global variable.
- If the variable is undefined Data returns false, false, nil.
- If the variable has a value but no descendants returns true, false, nil
- If the variable has descendants but no value returns false, true, nil
- If the variable has a value and descendants returns true, true, nil in case of any error returns false, false, error
func Get ¶
Get returns the value of provided glvn if it has a value. If the variable has no value, the function returns a value specified by an optional second argument, and otherwise returns an empty string. Sample usage: gogtm.Get("test","nil")
Example ¶
package main import ( "fmt" "github.com/szydell/gogtm" ) func main() { data, err := gogtm.Get("^test", "ababababababababa") if err != nil { fmt.Println("gogtm.Get failed: ", err.Error()) } if data == "ababababababababa" { fmt.Println("Global ^test empty, default value returned") } else { fmt.Println("Value of global ^test is: " + data) } }
Output:
func Kill ¶
Kill deletes global variable and its descendant nodes
Example ¶
package main import ( "fmt" "github.com/szydell/gogtm" ) func main() { err := gogtm.Kill("^test") if err != nil { fmt.Println("gogtm.Kill failed: ", err.Error()) } }
Output:
func Order ¶
Order returns the next key or glvn You can also provide flag '-1' in dir variable. This way order will return previous key or glvn.
Example ¶
package main import ( "fmt" "github.com/szydell/gogtm" ) func main() { data, err := gogtm.Order("^test", "") if err != nil { fmt.Println("gogtm.Order failed", err.Error()) } rev, err := gogtm.Order("^test", "-1") if err != nil { fmt.Println("gogtm.Order with the reverse direction flag failed", err.Error()) } fmt.Printf("gogtm.Order returned %s, in the reverse direction returned %s", data, rev) }
Output:
func Query ¶
Query returns the next subscripted local or global variable node name, independent of level, which follows the node specified by its argument in M collating sequence and has a data value.
Example ¶
package main import ( "fmt" "github.com/szydell/gogtm" ) func main() { data, err := gogtm.Query("^test") if err != nil { fmt.Println("gogtm.Query failed", err.Error()) } fmt.Printf("gogtm.Query returned %s.", data) }
Output:
func Set ¶
Set saves value to global in gt.m db Sample usage: gogtm.Set("^test","value")
Example ¶
package main import ( "fmt" "github.com/szydell/gogtm" ) func main() { err := gogtm.Set("^test", "aaa") if err != nil { fmt.Println("gogtm.Set failed: ", err.Error()) } }
Output:
func ZKill ¶
ZKill deletes the data value for a variable name without affecting the nodes descended from that node.
Example ¶
package main import ( "fmt" "github.com/szydell/gogtm" ) func main() { err := gogtm.ZKill("^test") if err != nil { fmt.Println("gogtm.ZKill failed: ", err.Error()) } }
Output:
Types ¶
This section is empty.