Skip to content

Instantly share code, notes, and snippets.

@gabesullice
Created February 26, 2015 21:30
Show Gist options
  • Save gabesullice/e1935a75ccba1e16b294 to your computer and use it in GitHub Desktop.
Save gabesullice/e1935a75ccba1e16b294 to your computer and use it in GitHub Desktop.
Go lang DB Connection Config
func NewStorage(settings ...StorageConfig) *Storage {
var s Storage
s.ConnectOpts = r.ConnectOpts{
Address: "localhost:28015",
Database: "dbname",
MaxIdle: 10,
Timeout: time.Second * 10,
}
for _, setting := range settings {
setting.Configure(&s)
}
session, err := r.Connect(s.ConnectOpts)
if err != nil {
log.Fatalln(err.Error())
}
s.Session = session
return &s
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment