Created
June 5, 2020 14:55
-
-
Save aaronstaves/1806347bc2a012354ec8e6399c8a7a16 to your computer and use it in GitHub Desktop.
Go methods vs funcs - methods
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
// 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