You need to enable JavaScript to run this app.
File Storage vePFS

File Storage vePFS

Copy page
Download PDF
Go SDK
Code example
Copy page
Download PDF
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.​
​
package main​
​
import (​
"fmt"​
"os"​
​
"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"​
)​
​
var client *vepfs.VEPFS​
​
func initClient() {​
// See the client initialization section for details​
}​
​
func createFileSystem() {​
zoneId := "cn-beijing-a"​
fileSystemName := "go_sdk_test"​
fileSystemType := "VePFS"​
protocolType := "VePFS"​
chargeType := "PayAsYouGo"​
capacity := int32(6)​
storeType := "Advance_100"​
vpcId := "vpc-11w4ygf1zls7*************"​
subnetId := "subnet-11wlfzpho**************"​
​
// Use the CreateFileSystem API to create a file system​
resp, err := client.CreateFileSystem(&vepfs.CreateFileSystemInput{​
ZoneId: &zoneId,​
FileSystemName: &fileSystemName,​
FileSystemType: &fileSystemType,​
ProtocolType: &protocolType,​
ChargeType: &chargeType,​
Capacity: &capacity,​
StoreType: &storeType,​
SubnetId: &subnetId,​
VpcId: &vpcId,​
})​
​
if err != nil {​
fmt.Printf("Error when calling CreateFileSystem, err: %v\n", err)​
os.Exit(1)​
}​
​
fmt.Println(resp)​
}​
​
func main() {​
initClient()​
createFileSystem()​
}​
​
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.​
​
package main​
​
import (​
"fmt"​
"os"​
​
"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"​
)​
​
var client *vepfs.VEPFS​
​
func initClient() {​
// See the client initialization section for details​
}​
​
func describeFileSystems() {​
// Specify the file system ID to query​
fileSystemId := "vepfs-cn**************"​
​
// List file systems by calling the DescribeFileSystems API​
resp, err := client.DescribeFileSystems(&vepfs.DescribeFileSystemsInput{​
FileSystemIds: &fileSystemId,​
})​
​
if err != nil {​
fmt.Printf("Error when calling DescribeFileSystems, err: %v\n", err)​
os.Exit(1)​
}​
​
fmt.Println(resp)​
}​
​
func main() {​
initClient()​
describeFileSystems()​
}​
​
​
Last updated: 2026.03.03 10:39:10