So the tricky part here is that you are looking at a non-model prokayote and you need GO to gene mappings to do the kind of analysis that you propose. Where could you find these? Well that depends on just how 'non-model' your organism is... If your organism doesn't have assigned gene IDs and associated GO terms, then you are going to have to do some extra work up front in order to infer them somehow.
But if your organism has gene IDs, then there are several possible. One is to use the mappings from UniProt. You can often get this kind of information by using the UniProt.ws package if your organism has a valid taxonomy id. Here is an example of what that would look like
library(UniProt.ws) up <- UniProt.ws(511145) res <- select(up, keys(up,'UNIPROTKB'), 'GO-ID', 'UNIPROTKB')
Hope that helps,