The OpenText driver for Go
-
Go 1.12 or higher
-
OpenText 16.x
go get -u github.com/itcomusic/ot
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, err := ss.GetToken(context.Background(), "test", "test")
if err != nil {
log.Fatal(err)
}
sst := ot.NewEndpoint("127.0.0.1").Token(token)
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)
}
The OT Go driver is licensed under the MIT