TzPro Go Installation
go get -u github.com/trilitech/tzpro-go
Then import, using
import "github.com/trilitech/tzpro-go/tzpro"
Initializing the TzPro SDK Client
All functions are exported through a Client object. For convenience we have defined two default clients tzpro.DefaultClient for mainnet and tzpro.IpfsClientfor our IPFS gateway. You may construct custom clients for different API URLs like so:
c, err := tzpro.NewClient("https://api.tzpro.io", nil)
// set an API key if you use the TzPro API
c.WithApiKey("YOUR-TZPRO-API-KEY")
You can also export your TzPro API as environment variable before launching your Go program
export TZPRO_API_KEY=YOUR-TZPRO-API-KEY
Custom RPC client configuration
The default configuration should work just fine, but if you need special timeouts, proxy or TLS settings you may use a custom http.Client as second argument.
import (
    "crypto/tls"
    "log"
    "net"
    "net/http"
    "github.com/trilitech/tzpro-go/tzpro"
)
func main() {
    hc := &http.Client{
        Transport: &http.Transport{
            Dial: (&net.Dialer{
                Timeout:   2 * time.Second,
                KeepAlive: 180 * time.Second,
            }).Dial,
            TLSClientConfig: &tls.Config{
                InsecureSkipVerify: true,
            }
        }
    }
    c, err := tzpro.NewClient("https://my-private-index.local:8000", hc)
    if err != nil {
        log.Fatalln(err)
    }
}