Created
August 10, 2016 21:09
-
-
Save xyproto/08aa02cbdec33f5f0ff00a2183db29f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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