gogtm

package module
v0.0.0-...-4767082 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2018 License: Apache-2.0 Imports: 11 Imported by: 1

README

GoDoc GoReport Build Status

gogtm

Package gogtm enables connection to gt.m database using C API.

license

Licensed under the Apache License, Version 2.0 - https://github.com/szydell/gogtm/blob/master/LICENSE

based on

gtmaccess.ci and _gtmaccess.m are based on examples found here: http://tinco.pair.com/bhaskar/gtm/doc/books/pg/UNIX_manual/index.html

Documentation

Overview

Package gogtm enables access to gt.m database

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Data

func Data(global string) (value, descendent bool, err error)

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

func Get(global string, opt string) (string, error)

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 GvStat

func GvStat() (string, error)

GvStat returns gvstat for all regions Sample usage: gogtm.GvStat()

func Kill

func Kill(global string) error

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

func Order(global string, dir string) (string, error)

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

func Query(global string) (string, error)

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

func Set(global string, val string) error

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 Start

func Start() error

Start should be used as the initiator of connection to gt.m

func Stop

func Stop() error

Stop closes the connection gently.

func Xecute

func Xecute(code string) error

Xecute runs the M code

func ZKill

func ZKill(global string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL