Skip to content

Instantly share code, notes, and snippets.

@aaronstaves
Created June 5, 2020 14:55
Show Gist options
  • Save aaronstaves/1806347bc2a012354ec8e6399c8a7a16 to your computer and use it in GitHub Desktop.
Save aaronstaves/1806347bc2a012354ec8e6399c8a7a16 to your computer and use it in GitHub Desktop.
Go methods vs funcs - methods
// MyHandler Defintion
type MyHandler struct {
newrelic *newrelic.Application
configuration *configuration.Configuration
myService *sling.Sling
myDB dynamo.IClient
}
//New MyHandler constructor
func NewMyHandler(newrelic *newrelic.Application, config *configuration.Configuration, service *sling.Sling, db dynamo.IClient) *BuilderMessageHandler {
return &MyHandler{
newrelic: newrelic,
configuration: config,
myService: service,
myDB: db
}
}
func (s MyHandler) DoDBThing(querythinger string) error {
s.newrelic.txn() // whatever
s.myDB.query(querythinger, s.newrelic)
}
func (s MyHandler) DoServiceThing(querythinger string) error {
s.newrelic.txn() // whatever
s.myService.Do(querythinger)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment