Get file history for a specific file

The following is an example of how to get the file history for a specific file using P4 API for Go.

Copy
// Run filelog for a specific file
filelog, err := p4api.RunFilelog("//depot/example.txt")
if err != nil {
    fmt.Println("Error fetching filelog:", err)
    return
}

// Print file history
for _, file := range filelog {
    fmt.Println("File:", file.Name)
    for _, rev := range file.Revisions {
        fmt.Printf("Revision %d: %s by %s@%s\n", rev.Rev, rev.Action, rev.User, rev.Client)
        fmt.Println("Description:", rev.Desc)
    }
}