how do i use this function in go sdk to get all th...
# permit-saas
p
how do i use this function in go sdk to get all the permissions of the user.? (Get User Permission)
a
Hi @Pratham Khodwe, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
The Go SDK provides the
GetUserPermissions
function to retrieve all permissions for a user. (1) Here's how to use it:
Copy code
user := enforcement.UserBuilder("<mailto:john@doe.com|john@doe.com>") .Build()
permissions, err := Permit.GetUserPermissions(user, "tenant1", "tenant2")
You can also use
GetUserPermissionsWithOptions
for more control:
Copy code
user := enforcement.UserBuilder("<mailto:john@doe.com|john@doe.com>") .Build()
permissions, err := Permit.GetUserPermissionsWithOptions(user, 
    enforcement.WithTenants([]string{"tenant1", "tenant2"}) ,
    enforcement.WithResources([]string{"resource1", "resource2"}) ,
    enforcement.WithResourceTypes([]string{"document", "file"}) ,
    enforcement.WithContext(map[string]interface{}{"key": "value"}) ,
)
The function returns a
UserPermissions
map containing: •
Tenant
details •
Resource
information (if specified) •
Permissions
array listing allowed actions •
Roles
array listing assigned roles Each tenant's permissions are keyed by tenant ID in the returned map.
Thanks for the feedback, glad I was helpful.
permit check 1