Create digioceancloudconfig.json
in your HOME/.gocloud directory as follows:
{
"DigiOceanAccessToken": "xxxxxxxxxxxx"
}
You can also set the credentials as environment variables:
export DigiOceanAccessToken = "xxxxxxxxxxxx"
import "github.com/cloudlibz/gocloud/gocloud"
digioceancloud, _ := gocloud.CloudProvider(gocloud.Digioceanprovider)
create := map[string]interface{}{
"DomainName": "example.com",
"Type": "A",
"Name": "www",
"Data": "162.10.66.0",
"Priority": nil,
"Port": nil,
"TimeToLive": 1800,
"Weight": nil,
"Flags": nil,
"Tag": nil,
}
resp, err := digioceancloud.CreateDns(create)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
delete1 := map[string]string{
"DomainName": "example.com",
"RecordID": "28448433",
}
resp, err := digioceancloud.DeleteDns(delete1)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
listRecords := map[string]string{
"DomainName": "example.com",
}
resp, err := digioceancloud.ListDns(listRecords)
response := resp.(map[string]interface{})
fmt.Println(response["body"])