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

P4 API for Go Documentation | 2025.1

# Connect to the P4 Server

The following is an example of how to connect to the P4 Server 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
    21
    22
    import (
        "fmt"
        "p4"
    )

    p4api := p4.New()
    defer p4api.Close()

    // Set connection details
    p4api.SetPort("perforce:1666")
    p4api.SetUser("username")
    p4api.SetPassword("password")

    // Connect to the P4 server
    connected, err := p4api.Connect()
    if err != nil {
        fmt.Println("Error connecting to P4 server:", err)
        return
    }
    if connected {
        fmt.Println("Connected to P4 server.")
    }

Your search for returned results