← Credentials | Endpoint(中文) | Transport →
Default
If
Endpointis not specified, the SDK uses Automatic Endpoint Resolution.
func main() {
region := "cn-beijing"
config := volcengine.NewConfig().
WithCredentials(credentials.NewEnvCredentials()).
WithRegion(region).
WithEndpoint("<example>.<regionId>.volcengineapi.com")
sess, err := session.NewSession(config)
if err != nil {
panic(err)
}
}func main() {
regionId := "cn-beijing"
config := volcengine.NewConfig().
WithCredentials(credentials.NewEnvCredentials()).
WithRegion(regionId)
sess, err := session.NewSession(config)
if err != nil {
panic(err)
}
}Volcengine provides a flexible endpoint resolution mechanism. The SDK automatically builds the endpoint based on service name and region, and supports DualStack.
-
Whether the region is in the bootstrap list
Built-in list implementation:
./volcengine/volcengineutil/url.go#bootstrapRegion.Only predefined regions (e.g.,
cn-beijing-autodriving,ap-southeast-2) or user-configured regions are auto-resolved; others fall back toopen.volcengineapi.com.You can extend the list via env var
VOLC_BOOTSTRAP_REGION_LIST_CONForcustomBootstrapRegion. -
DualStack support (IPv6)
Enable via
useDualStack=trueor env varVOLC_ENABLE_DUALSTACK=true. Priority:useDualStack>VOLC_ENABLE_DUALSTACK.When enabled, the suffix changes from
volcengineapi.comtovolcengine-api.com. -
Construct endpoint based on service name and region
- Global services (e.g.,
CDN,IAM):<service>.volcengineapi.com(orvolcengine-api.comwhen DualStack is enabled). Example:cdn.volcengineapi.com. - Regional services (e.g.,
ECS,RDS):<service>.<region>.volcengineapi.comis used as the default endpoint. Example:ecs.cn-beijing.volcengineapi.com.
- Global services (e.g.,
func main() {
regionId := "cn-beijing"
config := volcengine.NewConfig().
WithCredentials(credentials.NewEnvCredentials()).
WithRegion(regionId).
WithUseDualStack(true).
WithBootstrapRegion(map[string]struct{}{
"custom_example_region1": {},
"custom_example_region2": {},
})
sess, err := session.NewSession(config)
if err != nil {
panic(err)
}
}| Global service | DualStack | Format |
|---|---|---|
| Yes | Yes | {Service}.volcengine-api.com |
| Yes | No | {Service}.volcengineapi.com |
| No | Yes | {Service}.{region}.volcengine-api.com |
| No | No | {Service}.{region}.volcengineapi.com |
Whether a service is global depends on the service itself and cannot be changed. See: ./volcengine/endpoints/standard_resolver.go#ServiceInfos.
package main
import (
"github.com/volcengine/volcengine-go-sdk/volcengine"
"github.com/volcengine/volcengine-go-sdk/volcengine/credentials"
"github.com/volcengine/volcengine-go-sdk/volcengine/endpoints"
"github.com/volcengine/volcengine-go-sdk/volcengine/session"
)
func main() {
regionId := "cn-beijing"
config := volcengine.NewConfig().
WithCredentials(credentials.NewEnvCredentials()).
WithEndpointResolver(endpoints.NewStandardEndpointResolver()).
WithRegion(regionId).
WithUseDualStack(true)
sess, err := session.NewSession(config)
if err != nil {
panic(err)
}
}← Credentials | Endpoint(中文) | Transport →