Skip to content

Instantly share code, notes, and snippets.

@xyproto
Created August 10, 2016 21:09
Show Gist options
  • Save xyproto/08aa02cbdec33f5f0ff00a2183db29f6 to your computer and use it in GitHub Desktop.
Save xyproto/08aa02cbdec33f5f0ff00a2183db29f6 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/xyproto/permissionwrench"
"github.com/xyproto/simplehstore"
)
func main() {
perm, err := permissionwrench.New()
if err != nil {
fmt.Println("Could not open database")
return
}
userstate := perm.UserState()
// A bit of checking is needed, since the database backend is interchangeable
if puserstate, ok := userstate.(*permissionwrench.UserState); ok {
if host, ok := puserstate.Host().(*simplehstore.Host); ok {
db := host.Database()
fmt.Printf("PostgreSQL database: %v (%T)\n", db, db)
}
} else {
fmt.Println("Not using the PostgreSQL database backend")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment