- Documentation
File Storage vePFS
SDK Reference
Go SDK
Initialize the client
Go SDK
Initialize the client
Initialize the client
The vePFS file storage Go SDK supports initializing the client using Session mode. A vePFS file storage client created via Session mode enables reuse of HTTP/HTTPS resources, such as connections or requests, at the underlying layer. When multiple clients need to be initialized for operations, using Session mode enhances client performance. This article explains how to initialize the client using Session mode.
Prerequisites
- When initializing the client, you need to include the following information:
- The account's Access Key ID (AK) and Secret Access Key (SK). For information on how to obtain AKSK, seeView AKSK Information.
- Region information. For supported Regions of vePFS File Storage, see Service Address.
Configure environment variables
Hardcoding AccessKey in business code poses security risks. We recommend managing AccessKey by configuring environment variables.
- The steps to configure environment variables are as follows:
export VOLCENGINE_ACCESS_KEY_ID=<Your AccessKey ID>
export VOLCENGINE_ACCESS_KEY_SECRET=<Your AccessKey Secret>
- The steps to configure environment variables are as follows:
- Create a new environment variable file, add environment variables VOLCENGINE_ACCESS_KEY_ID and VOLCENGINE_ACCESS_KEY_SECRET, and input your AccessKey ID and AccessKey Secret.
- Restart the Windows system.
Initialize the client
Use the following code to initialize the client.
"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"
config *volcengine.Config
ak = os.Getenv("VOLCENGINE_ACCESS_KEY_ID")
sk = os.Getenv("VOLCENGINE_ACCESS_KEY_SECRET")
config = volcengine.NewConfig().WithCredentials(credentials.NewStaticCredentials(ak, sk, "")).WithRegion(region)
sess, err = session.NewSession(config)
fmt.Printf("Failed to create session, err: %v\n", err)
client = vepfs.New(sess)
Last updated: 2026.03.03 10:39:10