Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.
/ ot Public archive

The Go driver for OpenText

License

Notifications You must be signed in to change notification settings

itcomusic/ot

Repository files navigation

OT Go Driver GoDoc Coverage Status

The OpenText driver for Go



Requirements

  • Go 1.12 or higher

  • OpenText 16.x

Installation

go get -u github.com/itcomusic/ot

Usage

To get started with the driver, import the ot package, create a ot.Endpoint and set user to future authentication to your running OpenText server:

ss := ot.NewEndpoint("127.0.0.1").User("test", "test")

To do this in a single step, you can use the Call function:

var res map[string]interface{}
ctx, _ = context.WithTimeout(context.Background(), 30*time.Second)
if err := ss.Call(ctx, "service.method", oscript.M{"argName", 1}, &res); err != nil {
    log.Fatal(err)
}

A context does not stop execution of a request in the opentext, it closes only socket.

Token

token, err := ss.GetToken(context.Background(), "test", "test")
if err != nil {
    log.Fatal(err)
}
sst := ot.NewEndpoint("127.0.0.1").Token(token)

Attributes

To set many attributes by types at once.

if err := cat.Set(
    ot.AttrInt("attr1", 1)
    ot.AttrString("attr2", "hello")
    ot.AttrBool("attr3", true)
    ot.AttrTime("attr4", time.Now())); err != nil {
    log.Fatal(err)
}

To get attribute with explicit type.

var attr1 int
if err := cat.Int("attr1", &attr1); err != nil {
    log.Fatal(err)
}

License

The OT Go driver is licensed under the MIT