The Official Golang Library for Retarus Messaging Services Retarus-Go allows you to easily integrate Retarus's suite of messaging services into your Golang applications. Whether you need to send SMS or Fax messages, this library has got you covered.
To install the Retarus-Go library, run the following command:
go get github.com/retarus/retarus-go
Before making any requests, you'll need to initialize the client. Here's how you can do it, but it is the same for all services:
import "github.com/retarus/retarus-go"
// reads the credentials from system env variables.
config := retarus.fax.NewConfigFromEnv(Europe)
client := retarus.fax.NewClient(config)
As you'll observe, we employ the NewConfigFromEnv function. This approach utilizes the credentials specified in the operating system's environment variables, necessitating that these values be exported accordingly.
export retarus_username=value
export retarus_password=value
export retarus_cuno=yourCuno
Here's a basic example to send a Fax:
job := fax.Job{
Recipients: []fax.Recipient{
{
Number: "00498923422342", // number to send to
},
},
Documents: []fax.Document{
{
Name: "test.txt", // local document to send
Data: "dGVzdGZheAo=", // test fax
},
},
}
jobID, err := client.Send(job)
if err != nil {
fmt.Println("Error: ", err)
}
fmt.Println("JobId: ", jobID)
For more comprehensive examples, please refer to the examples
directory in the repository.
Retarus-Go currently supports the following services:
- Fax
- SMS
The library allows you to specify a datacenter region when configuring your service client. Supported regions are:
- Europe
- America
- Switzerland
- Singapore
For additional information or to get support, visit our Knowledge Center.