Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 API for Go Documentation | 2025.1

# Create and fetch labels

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

Copy

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    // 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)
    }

Your search for returned results