Re: [go-nuts] What is recommended way to initialize and keep prepared statements in go Lang

2019-04-13 Thread Marcin Romaszewicz
Do you mean a SQL prepared statement? Check out the database/sql package. The database connection abstraction has a Prepare function which creates a statement. Keep in mind, that based on your level of concurrency, the statement will be re-prepared in each new connection that's opened up on your b

[go-nuts] Re: how to use an instance across functions in a package w/o global vars

2019-04-13 Thread alex via golang-nuts
While the expected r/w patterns will certainly influence the amount of pain you may feel from using "global state", I would not consider it to be the main deciding factor. Now, please keep in mind that this whole topic is more a matter of coding style and trade-offs, not necessarily right-or-wr

[go-nuts] Re: how to use an instance across functions in a package w/o global vars

2019-04-13 Thread itmitica
To summarize. - w package-level var is not going to be subject of modification while being read. No problems to solve, carry on with package-level vars. - w package-level var is going to be subject of modification while being read. Problems arise, stop using package-level vars. Sol

[go-nuts] What is recommended way to initialize and keep prepared statements in go Lang

2019-04-13 Thread shrinath136
Hi Team , I am new in go lang ,I want to know is there any recommended way in go lang to create prepare statement in go lang on application start and pass it to multiple http handler so that query can be done inside those http handlers. -- You received this message because you are subscribed to

[go-nuts] Re: Inject Mock Instead of Actual Implementation in Tests, Using "wire"

2019-04-13 Thread Kaveh Shahbazian
BTW I am aware that some build tag tricks can be used to achieve this. I was wondering it there is an idiomatic way or any best practices for using wire. On Saturday, April 13, 2019 at 3:19:58 PM UTC+2, Kaveh Shahbazian wrote: > > Assume wire is going to be used for dependency injection here. An

Re: [go-nuts] Re: Learning Data Structures and algorithms with Golang

2019-04-13 Thread Bhagvan Kommadi
thanks a ton. going forward, i will post according to the gopher code of the conduct. On Sat, Apr 13, 2019 at 6:57 PM Hemant Singh wrote: > I agree with Ian. > > My 2 cents. This is a Golang-nuts mailer. Any book on the language may > be useful to users to read. > > - Hemant > > On Fri, Apr 1

Re: [go-nuts] Re: Learning Data Structures and algorithms with Golang

2019-04-13 Thread Hemant Singh
I agree with Ian. My 2 cents. This is a Golang-nuts mailer. Any book on the language may be useful to users to read. - Hemant On Fri, Apr 12, 2019 at 6:59 PM Ian Lance Taylor wrote: > On Fri, Apr 12, 2019 at 3:55 PM wrote: > > > > Bhagvan's disgrceful misuse of this forum to support his com

[go-nuts] Inject Mock Instead of Actual Implementation in Tests, Using "wire"

2019-04-13 Thread Kaveh Shahbazian
Assume wire is going to be used for dependency injection here. And we have a provider function called NewService that returns an interface. There is the actual implementation for that interface that - for example - connects to PostgreSQL. And we have also the mock for that interface. Now we n