I have a resource and admin role created for a use...
# permit-saas
p
I have a resource and admin role created for a user under a tenant , what it is the go syntax to check for the permission
a
Hi @Pratham Khodwe, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
To check permissions in Go for a user with an admin role under a tenant, use the following syntax (1) :
Copy code
resource := enforcement.ResourceBuilder("document") .WithTenant("tenant") .Build()
const permitted = await permit.check(user, "create", resource) ;
For a complete example with user and resource building :
Copy code
user := enforcement.UserBuilder("<mailto:john@doe.com|john@doe.com>") .Build()
resource := enforcement.ResourceBuilder("document") .Build()
permitted, err := Permit.Check(user, "create", resource)
if err != nil {
    return
}
if permitted {
    // Let the user read the resource
} else {
    // Deny access
}
When checking permissions for resources within a specific tenant, you need to include the tenant in the resource builder using
.WithTenant("tenant")
where "tenant" is either the tenant id or tenant key .
To learn more, see the sources I considered: [[1] Running a demo](https://docs.permit.io/overview/connecting-your-app)
Thanks for the feedback, glad I was helpful.