The way I've been doing this recently is to write two methods for each
statement, one to prepare it and one to use it.
That way the SQL code sits next to the Exec or Query statement that uses
it, making it easier to understand what's going on.

Here's some example code showing the way we've been structuring this. It
would normally be split across several files (I've left comments where I'd
split it).

https://play.golang.org/p/fh9b7loZkLJ

It's a little tedious to do this, but eliminates a few common sources of
errors, and ends up quite readable IMHO.

Hope this helps,

  rog.


On Sat, 13 Apr 2019 at 18:58, <shrinath...@gmail.com> wrote:

> 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 the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to