- Documentation
File Storage vePFS
SDK Reference
Go SDK
Code example
Code example
This article provides code examples of the vePFS Go SDK for file storage for your reference.
Prerequisites
Set request timeout
When using the vePFS Go SDK to call file storage APIs, there is no timeout set by default. You can specify the client's request timeout when initializing the client using WithHTTPClient(&http.Client{Timeout: <timeout> * time.Second}). If the request is not completed within this period, it will be terminated and a timeout error will be reported. For example, you can set the client request timeout to 30 seconds using the following code.
config = volcengine.NewConfig().WithCredentials(credentials.NewStaticCredentials(ak, sk, "")).WithRegion(region).WithHTTPClient(&http.Client{Timeout: 30 * time.Second})
Creating file systems
tip
For information about the definition, value range, and other details of the parameters used in the SDK code below, see CreateFileSystem. "github.com/volcengine/volcengine-go-sdk/service/vepfs"
"github.com/volcengine/volcengine-go-sdk/volcengine"
"github.com/volcengine/volcengine-go-sdk/volcengine/credentials"
"github.com/volcengine/volcengine-go-sdk/volcengine/session"
func createFileSystem() {
zoneId := "cn-beijing-a"
fileSystemName := "go_sdk_test"
fileSystemType := "VePFS"
chargeType := "PayAsYouGo"
storeType := "Advance_100"
vpcId := "vpc-11w4ygf1zls7*************"
subnetId := "subnet-11wlfzpho**************"
resp, err := client.CreateFileSystem(&vepfs.CreateFileSystemInput{
FileSystemName: &fileSystemName,
FileSystemType: &fileSystemType,
ProtocolType: &protocolType,
ChargeType: &chargeType,
fmt.Printf("Error when calling CreateFileSystem, err: %v\n", err)
List file systems
tip
For information about the definition, value range, and other details of the parameters used in the SDK request below, see DescribeFileSystems. "github.com/volcengine/volcengine-go-sdk/service/vepfs"
"github.com/volcengine/volcengine-go-sdk/volcengine"
"github.com/volcengine/volcengine-go-sdk/volcengine/credentials"
"github.com/volcengine/volcengine-go-sdk/volcengine/session"
func describeFileSystems() {
fileSystemId := "vepfs-cn**************"
resp, err := client.DescribeFileSystems(&vepfs.DescribeFileSystemsInput{
FileSystemIds: &fileSystemId,
fmt.Printf("Error when calling DescribeFileSystems, err: %v\n", err)
Last updated: 2026.03.03 10:39:10