go-sdk
This module is a connector library for the insanely fast HEXONET Backend API. For further informations visit our homepage and do not hesitate to contact us.
Requirements
Installed GO on OS-side as described here. Restart your machine after installing GO.
For developers: Visual Studio Code with installed plugin for Go Development described here.
VS Studio Code will ask you to install some plugins when you start developing a .go file e.g.: gopkgs, goreturns, gocode. Just confirm!
Getting Started
Clone the git repository into your standard go folder structure by go get github.com/hexonet/go-sdk
.
We have also a demo app available showing how to integrate and use our SDK. See here.
For development purposes
Now you can already start working on the project.
How to use this module in your project
Use govendor for the dependency installation: govendor fetch github.com/hexonet/go-sdk@<tag id>
. You can update this dependency later on by govendor sync github.com/hexonet/go-sdk@<new tag id>
.
The dependencies will be installed in subfolder "vendor". Import the module in your project as shown in the examples below.
For more details on govendor, please read the CheatSheet and also the developer guide. Knowing about the latter one is very important.
Development
Run Tests
Go to subfolder "test" and run go test
.
Release an Update
Simply make a PR / merge request.
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
Our future plan:
We use SemVer for versioning. For the versions available, see the tags on this repository.
As GO doesn't support versioning out of the box up to now, we suggest you save a copy of our module locally and use that copy.
That's the way google is also using it internally. We can not ensure that our repository module source code may not change and break (what we would basically call a major release).
Authors
- Kai Schwarz - lead development - PapaKai
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE file for details
How-to-use Examples
Session based API Communication
package main
import (
"github.com/hexonet/go-sdk/client"
"fmt"
)
func main() {
cl := client.NewClient()
cl.SetCredentials("test.user", "test.passw0rd", "")//username, password, otp code (2FA)
cl.UseOTESystem()
r := cl.Login()
if r.IsSuccess() {
fmt.Println("Login succeeded.")
cmd := map[string]string{
"COMMAND": "StatusAccount",
}
r = cl.Request(cmd)
if r.IsSuccess() {
fmt.Println("Command succeeded.")
r = cl.Logout()
if r.IsSuccess() {
fmt.Println("Logout succeeded.")
} else {
fmt.Println("Logout failed.")
}
} else {
fmt.Println("Command failed.")
}
} else {
fmt.Println("Login failed.")
}
}
Sessionless API Communication
package main
import (
"github.com/hexonet/go-sdk/client"
"fmt"
)
func main() {
cl := client.NewClient()
cl.SetCredentials("test.user", "test.passw0rd", "")
cl.UseOTESystem()
cmd := map[string]string{
"COMMAND": "StatusAccount",
}
r := cl.Request(cmd)
if r.IsSuccess() {
fmt.Println("Command succeeded.")
} else {
fmt.Println("Command failed.")
}
}
Documentation
Run godoc -http=:6060
on command line and access it via http://localhost:6060.
Navigate to "packages" > "apiconnector".
Alternative: See our SDK @ GoDoc.org
Resources
... the above go documentation server that comes also with further informations around GO.
Learn Go in Y Minutes
An Introduction to Programming in GO
Go by Example