client, err := storage.NewClient(storage.Options{
Name: "your-org",
Key: os.Getenv("PIERRE_PRIVATE_KEY"),
})
if err != nil {
return fmt.Errorf("failed to create client: %w", err)
}
ctx := context.Background() // or from an existing context
repo, err := client.CreateRepo(ctx, storage.CreateRepoOptions{
ID: "new-workspace",
})
if err != nil {
return fmt.Errorf("failed to create repository: %w", err)
}
builder, err := repo.CreateCommit(storage.CommitOptions{
TargetBranch: "main",
CommitMessage: "Get Started with Code Storage",
Author: storage.CommitSignature{
Name: "Your Name",
Email: "you@example.com",
},
})
if err != nil {
return fmt.Errorf("failed to create commit: %w", err)
}
result, err := builder.
AddFileFromString("README.md", "# Getting Started\n", nil).
AddFileFromString("main.go", "package main\n\nfunc main() {}\n", nil).
Send(ctx)
if err != nil {
return fmt.Errorf("failed to add file: %w", err)
}
fmt.Println("Commit SHA:", result.CommitSHA)