Create and fetch labels

The following is an example of how to create and fetch labels using P4 API for Go.

Copy
// Create a label
labelSpec := map[string]interface{}{
    "Label":       "my_label",
    "Description""This is a test label",
    "View0":       "//depot/...",
}
_, err := p4api.RunSave("label", labelSpec)
if err != nil {
    fmt.Println("Error creating label:", err)
else {
    fmt.Println("Label created successfully.")
}

// Fetch the label
label, err := p4api.RunFetch("label""my_label")
if err != nil {
    fmt.Println("Error fetching label:", err)
else {
    fmt.Println("Label details:", label)
}