This topic describes how to use DeleteConfig to delete configurations from Nacos and therefore reduce O&M costs through automation.
Description
You can call the following operation to delete configurations from Nacos.
DeleteConfig(param vo.ConfigParam) (bool, error)
Request parameters
Parameter | Type | Description |
---|---|---|
Response parameters
Type | Description |
---|---|
Boolean | Indicates whether the configuration is deleted. |
Examples
Go
format
package main
import (
"fmt"
"github.com/nacos-group/nacos-sdk-go/clients"
"github.com/nacos-group/nacos-sdk-go/common/constant"
"github.com/nacos-group/nacos-sdk-go/vo"
"time"
)
func main() {
//Use the values of End Point and Namespace ID on the Namespace Details page.
var endpoint = "${endpoint}"
var namespaceId = "${namespaceId}"
//Use the AccessKey ID and AccessKey secret of the RAM user.
var accessKey = "${accessKey}"
var secretKey = "${secretKey}"
clientConfig := constant.ClientConfig{
//
Endpoint: endpoint + ":8080",
NamespaceId: namespaceId,
AccessKey: accessKey,
SecretKey: secretKey,
TimeoutMs: 5 * 1000,
ListenInterval: 30 * 1000,
}
configClient, err := clients.CreateConfigClient(map[string]interface{}{
"clientConfig": clientConfig,
})
if err ! = nil {
fmt.Println(err)
return
}
var dataId = "com.alibaba.nacos.example.properties"
var group = "DEFAULT_GROUP"
//Delete the configuration.
success, err = configClient.DeleteConfig(vo.ConfigParam{
DataId: dataId,
Group: group})
if success {
fmt.Println("Config deleted successfully.")
}
}