Library in the language of GO
Greetings.
I tried very hard and did it all the same.
And so I'll start a small description of the library.
The source code for the library can be obtained from [address] (https://github.com/asuleymanov/golos-go).
This library is a continuation of the @void user.
The library is built according to the principle of installed and used. In its original form was not the correct implementation of the library. At the moment (I think) most of the problems are eliminated.
Installation
There are 2 options for installation:
- Copy.
- Installation using the language GO
go get github.com / asuleymanov / golos-go
Use
To use, you need to connect the library to your project import github.com/asuleymanov/golos-go/client
Next, you need to create an object (structure) for using the library.
Cls: = client.NewApi (" wss: //ws.golos.io "," golos ")
The first parameter is the gateway address, the second parameter is the system name (currently only two versions of "golos" and "steem" are used)
Note
The main thing is not to forget to close the gateway with the command defer cls.Rpc.Close ()
Further use is possible in two versions.
- Information option (Only obtaining information about CU)
- Active option. Use ready-made and create new functions for sending data to the CU. For this option, one more preparation is needed. Namely, it is necessary to provide initialization of keys. Without this, no data recording operation in the CU will work.
Initialization time:
Client.Key_List ["< username >"] = client.Keys {
PKey: "",
AKey: "",
OKey: "",
MKey: ""}
Explanations.
< Username > - the user name for which the list of keys is created
Then directly list the keys. This initialization system provides for the initialization of a specific key, i.e. Without indicating the others.
Example:
Client.Key_List [" <username> "] = client.Keys {PKey:" < key > "}
For the specified client only those operations which allow to use posting key will be accessible.
If you need to know what key for which operation you need, you can use the file in the library along the path:
github.com / asuleymanov / golos-go / client / ident_wif.go
This file contains the full list of operations and keys that are needed to use it.
Description of (ready-made) functions
At the moment, the library has the following functions:
Func (api * Client) Vote (user_name, author_name, permlink string, weight int)
Func (api * Client) Comment (user_name, author_name, ppermlink, body string)
Func (api * Client) Comment_Vote (user_name, author_name, ppermlink, body string, weight_post int)
Func (api * Client) DeleteComment (author_name, permlink string)
Func (api * Client) Post (author_name, title, body string, tags [] string)
Func (api * Client) Post_Vote (author_name, title, body string, tags [] string, weight_post int)
Func (api * Client) Follow (follower, following string)
Func (api * Client) Unfollow (follower, following string)
Func (api * Client) Ignore (follower, following string)
Func (api * Client) Notice (follower, following string)
Func (api * Client) Reblog (user_name, author_name, permlink string)
Func (api * Client) Witness_Vote (user_name, witness_name string, approv bool)
Func (api * Client) Transfer (from_name, to_name, memo, ammount string)
Further expansion of functionality is planned. But already at the moment the library can be used to write microservices (for which in most cases the GO language is intended).
P.S. I express my deep gratitude to @steepshot team for helping to sort out the serialization system.