Skip to content

Instantly share code, notes, and snippets.

@lcaballero
Created September 22, 2015 22:32
Show Gist options
  • Save lcaballero/66d371a335672a27e74c to your computer and use it in GitHub Desktop.
Save lcaballero/66d371a335672a27e74c to your computer and use it in GitHub Desktop.
Go example of connection based handling
type Db struct {
db *bolt.DB
err error
}
func (d *Db) start() *bolt.DB {
d.db, d.err = bolt.Open("my.db", 0600, nil)
if d.err != nil {
fmt.Println(d.err)
}
go func() {
death.NewDeath(syscall.SIGINT, syscall.SIGTERM).WaitForDeath(d.db)
}()
return d.db
}
func NewDb() *Db {
return &Db{}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment