[go-nuts] Re: Reusing tcp connections on tunnels

2020-01-16 Thread hao dong
I don't think every net.Dial() creates an actually tcp connection to a 
server, this func is just an abstract of system call. Desingers of Go are 
so clever that will not do this stupid thing. I think I will make a test of 
that. 

On Friday, January 17, 2020 at 4:07:28 AM UTC+8, XXX ZZZ wrote:
>
> Hello,
>
> I'm trying to write an application that will basically serve as a tunnel 
> between some servers outside our network and our internal servers. For this 
> I've started using a snippet that creates a tcp listener and then dials to 
> a remote host. Code is shown here:
>
> https://play.golang.org/p/4wjCZFXq6Yg
>
> The code works just fine, however every time it gets a new request it 
> dials a new connection to the remote host, and then after all data has been 
> forwarded to both sides it closes them. I'm no expert on networking but 
> this looks like its just opening/closing tcp connections instead of just 
> reusing them, is this correct? if so, what would be the correct way of 
> resuing the connection? 
>
> Thanks!
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c3f42f36-7eb5-4e0a-9426-d79a805c9da8%40googlegroups.com.


Re: [go-nuts] Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread Eric S. Raymond
Everton Marques :
> See Go steadly growing over the years:
> 
> https://madnight.github.io/githut/#/stars/2019/4

Wait.  #4 in GitHub populaity, pasr C++ and C. amd people are *complaining*?

I've seen failure.  This isn't it.
-- 
http://www.catb.org/~esr/;>Eric S. Raymond


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/20200117000326.GA83117%40thyrsus.com.


[go-nuts] Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread Everton Marques
See Go steadly growing over the years:

https://madnight.github.io/githut/#/stars/2019/4

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/901f2970-4b78-4624-85cf-5e80125256f5%40googlegroups.com.


Re: [go-nuts] Re: Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread Robert Engels
Porsche’s sales are a tiny fraction of auto sales, but most in the industry 
consider it to be the best platform - and only wish they could emulate / afford 
to be in that conversation. 

> On Jan 16, 2020, at 2:10 PM, Liam  wrote:
> 
> 
> Open source is a rapidly growing movement across virtually all languages, but 
> still a small minority of all software. So the Trends graph is more revealing 
> than Github activity. Assembly language use on Github also increased by ~150%
> 
> There's no question that Go use is growing rather quickly. It's the mindshare 
> that I'm preoccupied with, because I'd expect that to impact Alphabet Inc's 
> budgeting calculus.
> 
> On a golang-dev thread recently, I raised the point that talking about "Go 2" 
> may have created a widespread misperception (esp among non-users) that a 
> backwards incompatible "v2.0" language is planned.
> 
> This comment on the last Redmonk survey is telling about Go's public 
> perception:
> 
> Go (-1): For the second run in a row, Go dropped one spot, this time out of a 
> tie with R for 15th back to 16th on our list. To be sure, placement in the 
> top twenty is by itself a remarkable achievement; many popular, widely used 
> and beloved languages lay well behind it. But for all of its credibility and 
> usage in widely used, popular projects, Go’s lack of versatility – perceived 
> or otherwise – has limited its upside. Go has remained a solidly top twenty 
> language, but has never placed higher than 14th, and that for only a single 
> quarter. It will also be interesting to see if any of the controversy 
> surrounding Go’s future direction – and the community’s input or lack thereof 
> into that – has any observable impact on the language’s traction moving 
> forward.
> 
> From https://redmonk.com/sogrady/2019/07/18/language-rankings-6-19/
> 
>> On Thursday, January 16, 2020 at 7:33:36 AM UTC-8, Amnon Baron Cohen wrote:
>> Go was originally conceived as a niche language. And if it does what we 
>> need, then I don't think 
>> we need to be particularly bothered if other languages are more "popular".
>> 
>> But when looking at language popularity, I am not sure that the number of 
>> google searches is the most meaningful metric.
>> 
>> Lines of code on github could be more interesting.
>> 
>> FWIW: Githubs octoverse shows shows a 147% growth in Go usage last year.
>> 
>> And more interesting growth stats can be found on the Go blog 
>> https://blog.golang.org/8years
>> 
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/5f40c9c1-2ca3-419e-b410-f0f835d63d04%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0920AC1A-AFAC-482E-BFFD-45CE36ACAE11%40ix.netcom.com.


Re: [go-nuts] Re: Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread Liam
Open source is a rapidly growing movement across virtually all languages, 
but still a small minority of all software. So the Trends graph is more 
revealing than Github activity. Assembly language use on Github also 
increased by ~150%

There's no question that Go use is growing rather quickly. It's the 
mindshare that I'm preoccupied with, because I'd expect that to impact 
Alphabet Inc's budgeting calculus.

On a golang-dev thread recently, I raised the point that talking about "Go 
2" may have created a widespread misperception (esp among non-users) that a 
backwards incompatible "v2.0" language is planned.

This comment on the last Redmonk survey is telling about Go's public 
perception:

*Go (-1): For the second run in a row, Go dropped one spot, this time out 
of a tie with R for 15th back to 16th on our list. To be sure, placement in 
the top twenty is by itself a remarkable achievement; many popular, widely 
used and beloved languages lay well behind it. But for all of its 
credibility and usage in widely used, popular projects, Go’s lack of 
versatility – perceived or otherwise – has limited its upside. Go has 
remained a solidly top twenty language, but has never placed higher than 
14th, and that for only a single quarter. It will also be interesting to 
see if any of the controversy surrounding Go’s future direction – and the 
community’s input or lack thereof into that – has any observable impact on 
the language’s traction moving forward.*

>From https://redmonk.com/sogrady/2019/07/18/language-rankings-6-19/

On Thursday, January 16, 2020 at 7:33:36 AM UTC-8, Amnon Baron Cohen wrote:
>
> Go was originally conceived as a niche language. And if it does what we 
> need, then I don't think 
> we need to be particularly bothered if other languages are more "popular".
>
> But when looking at language popularity, I am not sure that the number of 
> google searches is the most meaningful metric.
>
> Lines of code on github could be more interesting.
>
> FWIW: Githubs octoverse shows shows a 147% growth in Go usage last year.
>
> And more interesting growth stats can be found on the Go blog 
> https://blog.golang.org/8years
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5f40c9c1-2ca3-419e-b410-f0f835d63d04%40googlegroups.com.


[go-nuts] Reusing tcp connections on tunnels

2020-01-16 Thread XXX ZZZ
Hello,

I'm trying to write an application that will basically serve as a tunnel 
between some servers outside our network and our internal servers. For this 
I've started using a snippet that creates a tcp listener and then dials to 
a remote host. Code is shown here:

https://play.golang.org/p/4wjCZFXq6Yg

The code works just fine, however every time it gets a new request it dials 
a new connection to the remote host, and then after all data has been 
forwarded to both sides it closes them. I'm no expert on networking but 
this looks like its just opening/closing tcp connections instead of just 
reusing them, is this correct? if so, what would be the correct way of 
resuing the connection? 

Thanks!

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3497df63-df20-4e07-a2b8-db1a49159c2d%40googlegroups.com.


Re: [go-nuts] Sybase SQLAnywhere driver for Unix systems

2020-01-16 Thread Chris Burkert
Hello, we are working on a pure Go implementation of the TDS protocol for
https://github.com/SAP/go-ase (which is currently just a cgo driver). I am
not sure if TDS is also understood by SQLAnywhere but if so, then this may
help. I will see if I find more in the company and let you know.

reda laanait  schrieb am Di. 7. Jan. 2020 um 14:23:

>
> Hello,
>
> Is there a Golang driver for Sybase SQLAnywhere DB that works in a Unix
> system? I only find this , which
> works only on windows.
>
> Otherwise, Is there any workaround to fix that e.g implementing a wrapper
> of another language driver?
>
> Thanks
>
> --
> LAANAIT Ahmed Reda
> --
> Computer Engineer at
> TamTam international
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/CAJg1kZP_68-XsdSXHzkSm2mOPuP%2BptLpihCsmcOtLJ734XyZcw%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CALWqRZoqx2ioV--5VMnZwkKebA3CPXc6X7%3Dvb1m-x9cM80sYCQ%40mail.gmail.com.


Re: [go-nuts] [Proposal] database/sql: add interface that unite DB and Tx

2020-01-16 Thread Marcin Romaszewicz
I have that exact interface in all of my DB code, and I never use sql.Tx or
sql.DB directly. You don't need Go's libraries to adopt this at all, just
use your own.

On Wed, Jan 15, 2020 at 11:20 PM Mhd Shulhan  wrote:

> ## Problem
>
> At some point we have a function that receive an instance of database
> connection to query rows in specific table.
>
> Let's say that function F() accept DB that query table T.
>
> If function F() called with DB instance, it will query only rows that has
> been committed into database.
>
> IF function F() called with Tx instance, it will query all rows including
> the one that has not been committed yet into database.
>
> Since DB and Tx are different types, we will have two functions that
> almost have identical code,
>
> func F(db *sql.DB) (output int) {
>   q := `SELECT … FROM T WHERE …`
>   err := db.QueryRow(q).Scan()
>   …
>   return output
> }
>
> func FWithTx(tx *sql.Tx)(output int) {
>   q := `SELECT … FROM T WHERE …`
>   err := tx.QueryRow(q).Scan()
>   …
>   return output
> }
>
>
> ## Proposed solution
>
> Add an interface Session (the name is not fixed yet) to package sql with
> the following signature,
>
> type Session interface {
> func Exec(query string, args ...interface{}) (Result, error)
> func ExecContext(ctx context.Context, query string, args
> ...interface{}) (Result, error)
> func Prepare(query string) (*Stmt, error)
> func PrepareContext(ctx context.Context, query string) (*Stmt, error)
> func Query(query string, args ...interface{}) (*Rows, error)
> func QueryContext(ctx context.Context, query string, args
> ...interface{}) (*Rows, error)
> func QueryRow(query string, args ...interface{}) *Row
> func QueryRowContext(ctx context.Context, query string, args
> ...interface{}) *Row
> }
>
> Session interface is combination of DB and Tx that contains all identical
> methods.
>
>
> ## Rationale
>
> Without Session, user will have two functions that have the same code,
>
> By using Session, we can minimise duplicate code in the user level. for
> example using the previous problems definition the function F() become one,
>
> func F(session sql.Session)(output int) {
>   q := `SELECT … FROM T WHERE …`
>   err := session.QueryRow().Scan()
>   …
>   return output
> }
>
>
> ## Discussion
>
> Any thought about this proposal?
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/C8AB29FF-7A85-445A-B09E-A0E7CB322A4C%40gmail.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CA%2Bv29LsuLd_-LHqi4ZGadOihnY%3D8r4bYMe3T6ssVaCWYpcHN3A%40mail.gmail.com.


Re: [go-nuts] Unexpected evaluation order in a return statement with multiple operands

2020-01-16 Thread Jake Montgomery
I could not agree more with Axel's assessment, and wanted to emphisize it 
for any Go-noobs reading this. An important part of the go philosophy is to 
write code that is as clear and simple as possible. It is not about compact 
code, or 'clever' code. Code should be easy to understand, even when 
skimming. A return statement that returns a value, and modifies it in the 
same statement, would not pass code review for me. 

Just because you can, does not mean you should. 

On Wednesday, January 15, 2020 at 2:34:05 PM UTC-5, Axel Wagner wrote:
>
> And, just as an addendum: IMO, if the result depends on the order of 
> operations in a statement, prefer to rewrite it. Like, even if you are 
> satisfied with the behavior you are seeing *and* you can rely on it - it 
> should be clear by now that anyone looking at it will have to expand new 
> effort understanding it (and, you know, there might still be bugs in the 
> future). Rewriting the function call into its own statement gets rid of the 
> ambiguity and makes clear what's happening either way.
>
> On Wed, Jan 15, 2020 at 8:25 PM Paul Jolly > 
> wrote:
>
>> >   "when evaluating the operands of an expression, assignment, or return 
>> statement, all function calls, method calls, and communication operations 
>> are evaluated in lexical left-to-right order."
>>
>> My understanding goes as follows: the operands of the return statement
>> are i and modify(). The comma after "return statement" in the above
>> sentence is then important: because the only "function calls, method
>> calls, and communication operations" in that list of operands are (is)
>> modify().
>>
>> Hence when i (as in the first operand) is evaluated is not specified.
>> And therefore it's dangerous to rely on it being one value or another
>> (which it could be given the example you provide).
>>
>> There was even some discussion at the London Gophers November 2019
>> meetup (where the conundrum was very related
>>
>> https://docs.google.com/presentation/d/e/2PACX-1vQ07uP_ldnSYzpaNb5AlZZ-_tL2mZuoNfQgxvsTKSM4aglYR-nuvyrZ8nK__r3YQTo1vqH-Hmax3aXs/pub?slide=id.g6239d05d0e_0_1
>> )
>> about whether it would be possible to statically flag potential errors
>> like this.
>>
>> -- 
>> 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 golan...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/CACoUkn7KA0Z-TDypdvM%3Du%3DyVPHuHFmtD%3DiTV2c98Vm%3Dqn4NcPw%40mail.gmail.com
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/22823a87-11e9-413e-bbb0-abf6aa3b50d2%40googlegroups.com.


[go-nuts] Re: ngrok/sqlmw: an abstraction for database/sql interceptors and middleware

2020-01-16 Thread Alan Shreve
Forgot to paste in an example, see below:

func run(dsn string) {
// install the wrapped driver
sql.Register("postgres-mw", sqlmw.Driver(pq.Dirver{},
new(sqlInterceptor)))
db, err := sql.Open("postgres-mw", dsn)
...
}

type sqlInterceptor struct {
sqlmw.NullInterceptor
}

func (in *sqlInterceptor) StmtQueryContext(ctx context.Context, conn
driver.StmtQueryContext, query string, args []driver.NamedValue)
(driver.Rows, error) {
startedAt := time.Now()
rows, err := conn.QueryContext(ctx, args)
log.Debug("executed sql query", "duration",
time.Since(startedAt), "query", query, "args", args, "err", err)
return rows, err
}


On Thu, Jan 16, 2020 at 5:16 AM Alan Shreve 
wrote:

> Hi golang-nuts -
>
> This is an abstraction that we needed at ngrok. It allows you to
> intermediate calls to a database/sql Driver just like a client-side grpc
> interceptor would. This makes it an excellent abstraction layer upon which
> to build instrumentation and other middleware-like functionality.
>
> There are a number of similar projects which provided instrumentation for
> logging/tracing and a few others that were aimed solely at providing
> callbacks for instrumentation, but I realized a more general-purpose
> abstraction would provide more power to the programmer by providing the
> ability to intercept and modify calls and return values.
>
> Hope it's helpful to others. Feedback appreciated.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEn9ByH9RxyFVP4vmKc0CXVy6N-xKA8YERm3Ao28bKEjabu_8A%40mail.gmail.com.


[go-nuts] Re: ngrok/sqlmw: an abstraction for database/sql interceptors and middleware

2020-01-16 Thread Alan Shreve
And of course I forgot to include a link to the code as well. Sorry for all
the messages.

https://github.com/ngrok/sqlmw

On Thu, Jan 16, 2020 at 5:19 AM Alan Shreve 
wrote:

> Forgot to paste in an example, see below:
>
> func run(dsn string) {
> // install the wrapped driver
> sql.Register("postgres-mw", sqlmw.Driver(pq.Dirver{}, 
> new(sqlInterceptor)))
> db, err := sql.Open("postgres-mw", dsn)
> ...
> }
>
> type sqlInterceptor struct {
> sqlmw.NullInterceptor
> }
>
> func (in *sqlInterceptor) StmtQueryContext(ctx context.Context, conn 
> driver.StmtQueryContext, query string, args []driver.NamedValue) 
> (driver.Rows, error) {
> startedAt := time.Now()
> rows, err := conn.QueryContext(ctx, args)
> log.Debug("executed sql query", "duration", time.Since(startedAt), 
> "query", query, "args", args, "err", err)
> return rows, err
> }
>
>
> On Thu, Jan 16, 2020 at 5:16 AM Alan Shreve 
> wrote:
>
>> Hi golang-nuts -
>>
>> This is an abstraction that we needed at ngrok. It allows you to
>> intermediate calls to a database/sql Driver just like a client-side grpc
>> interceptor would. This makes it an excellent abstraction layer upon which
>> to build instrumentation and other middleware-like functionality.
>>
>> There are a number of similar projects which provided instrumentation for
>> logging/tracing and a few others that were aimed solely at providing
>> callbacks for instrumentation, but I realized a more general-purpose
>> abstraction would provide more power to the programmer by providing the
>> ability to intercept and modify calls and return values.
>>
>> Hope it's helpful to others. Feedback appreciated.
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEn9ByET-swom7eyu90i-e-BXnnbUr6h-%3DCRR1KtQspHQjYyEg%40mail.gmail.com.


[go-nuts] ngrok/sqlmw: an abstraction for database/sql interceptors and middleware

2020-01-16 Thread Alan Shreve
Hi golang-nuts -

This is an abstraction that we needed at ngrok. It allows you to
intermediate calls to a database/sql Driver just like a client-side grpc
interceptor would. This makes it an excellent abstraction layer upon which
to build instrumentation and other middleware-like functionality.

There are a number of similar projects which provided instrumentation for
logging/tracing and a few others that were aimed solely at providing
callbacks for instrumentation, but I realized a more general-purpose
abstraction would provide more power to the programmer by providing the
ability to intercept and modify calls and return values.

Hope it's helpful to others. Feedback appreciated.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEn9ByGbufnpDXG9BEZ%3DgmAU8YzKwis%2BJa_sJEBxLpqF-FqQdQ%40mail.gmail.com.


Re: [go-nuts] Re: [Proposal] database/sql: add interface that unite DB and Tx

2020-01-16 Thread Andrew Houghton
This may be helpful.

https://godoc.org/github.com/golang-sql/sqlexp#Querier

On Thu, Jan 16, 2020 at 1:09 AM Tamás Gulácsi  wrote:

> 2020. január 16., csütörtök 8:20:17 UTC+1 időpontban Shulhan a következőt
> írta:
>>
>> ## Problem
>>
>> At some point we have a function that receive an instance of database
>> connection to query rows in specific table.
>>
>> Let's say that function F() accept DB that query table T.
>>
>> If function F() called with DB instance, it will query only rows that has
>> been committed into database.
>>
>> IF function F() called with Tx instance, it will query all rows including
>> the one that has not been committed yet into database.
>>
>> Since DB and Tx are different types, we will have two functions that
>> almost have identical code,
>>
>> func F(db *sql.DB) (output int) {
>>   q := `SELECT … FROM T WHERE …`
>>   err := db.QueryRow(q).Scan()
>>   …
>>   return output
>> }
>>
>> func FWithTx(tx *sql.Tx)(output int) {
>>   q := `SELECT … FROM T WHERE …`
>>   err := tx.QueryRow(q).Scan()
>>   …
>>   return output
>> }
>>
>>
>> ## Proposed solution
>>
>> Add an interface Session (the name is not fixed yet) to package sql with
>> the following signature,
>>
>> type Session interface {
>> func Exec(query string, args ...interface{}) (Result, error)
>> func ExecContext(ctx context.Context, query string, args
>> ...interface{}) (Result, error)
>> func Prepare(query string) (*Stmt, error)
>> func PrepareContext(ctx context.Context, query string) (*Stmt, error)
>> func Query(query string, args ...interface{}) (*Rows, error)
>> func QueryContext(ctx context.Context, query string, args
>> ...interface{}) (*Rows, error)
>> func QueryRow(query string, args ...interface{}) *Row
>> func QueryRowContext(ctx context.Context, query string, args
>> ...interface{}) *Row
>> }
>>
>> Session interface is combination of DB and Tx that contains all identical
>> methods.
>>
>>
>> ## Rationale
>>
>> Without Session, user will have two functions that have the same code,
>>
>> By using Session, we can minimise duplicate code in the user level. for
>> example using the previous problems definition the function F() become one,
>>
>> func F(session sql.Session)(output int) {
>>   q := `SELECT … FROM T WHERE …`
>>   err := session.QueryRow().Scan()
>>   …
>>   return output
>> }
>>
>>
>> ## Discussion
>>
>> Any thought about this proposal?
>
>
>
> Just define the interface and use it - Go is not Java, iff a type
> statisfies an interface, then it also implements it!
>
> You can use anonymous interfaces also!
>
> ```
> func F(db interface { QueryRow() *sql.Row })(output int) {
>   q := `SELECT … FROM T WHERE …`
>   err := db.QueryRow().Scan(&
>>
>> output)
>>   …
>>   return output
>> }
>
> ```
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/a81bb8a1-bc68-487d-b678-dc3fd344e9ed%40googlegroups.com
> 
> .
>


-- 
- a.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOPexdjHHkB_cT9aJNOPv2_GD2P2jy6LbHe-U%3DNZWkbNbht7uw%40mail.gmail.com.


Re: [go-nuts] Re: Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread Amnon Baron Cohen
https://www.benfrederickson.com/ranking-programming-languages-by-github-users/

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/58fb16ef-90eb-45f4-8232-013262d23848%40googlegroups.com.


Re: [go-nuts] Re: How to query mongodb dynamically using Go interface

2020-01-16 Thread burak serdar
On Thu, Jan 16, 2020 at 9:08 AM  wrote:
>
> Hi,
>
> this is the JSON document in mongodb.
> {
> "sNssais": [{
> "sst": 0,
> "sd": "string"
> }],
> "nsiList": [
> "string"
> ],
> "ipv4Addresses": [
> "198.51.100.1"
> ],
> "ipv6Addresses": [
> "2001:db8:85a3::8a2e:370:7334"
> ],
> "amfInfo": {
> "amfSetId": "string",
> "taiList": [{
> "plmnId": {
> "mcc": "string",
> "mnc": "string"
> },
> "tac": "3022",
> "nid": "string"
> }],
> },
> "customInfo": {}
> }
>
> The args in the *.tac are string values, even if i set the type casting like 
> bson.M{"amfInfo.taiList.tac": args[0].(string)} it stiil do not match "3022" 
> args input.
> And yes, am looking for exact match.

That query with args[0] should work, provided args[0] is "3022". I
suggest you check the args values.

>
>
>
> On Thursday, January 16, 2020 at 5:04:40 PM UTC+2, Afriyie Abraham Kwabena 
> wrote:
>>
>> Hi,
>>
>> I have been trying to create a dynamic mongodb query using golang interface 
>> but the logical $or does not work.
>> It only return a documents when the input matches the bson.M{"sNssais.sst": 
>> args[0].(int32), "sNssais.sd": args[1].(string)}.
>> other matches like bson.M{"amfInfo.taiList.tac": args}, etc does not work 
>> even though a document in mongodb collection exist that matches the input 
>> value.
>> Any idea as how to do this? The function is as below
>>
>> func (m *NfInstanceDataAccess) FindIp(preferredNfInstances string, args 
>> ...interface{}) ([]model.NfProfile, bool) {
>> var ip []model.NfProfile
>> pipeline := bson.M{
>> "nfType": preferredNfInstances,
>> "$or": []interface{}{
>> bson.M{"sNssais.sst": args[0].(int32), "sNssais.sd": 
>> args[1].(string)},
>> bson.M{"amfInfo.taiList.tac": args},
>> bson.M{"smfInfo.taiList.tac": args},
>> bson.M{"upfInfo.taiList.tac": args},
>> },
>> }
>> filter := bson.M{"ipv4Addresses": true}
>> err := db.C(COLLECTION).Find(pipeline).Select(filter).All()
>> if err != nil {
>> return ip, false
>> }
>> return ip, true
>> }
>>
>>
>>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/37f74556-974f-4229-bd2f-6850bfa62620%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqrJRFnuy%3Dk6%2BdNvH1DR1fL3OVCB%2BSKWKzVpttERJW%2BhwQ%40mail.gmail.com.


Re: [go-nuts] Re: Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread David Riley
I'll be interested to see how this trend goes when they FINALLY pull the plug 
on Python 2.7 and everyone who's been kicking the can down the road for the 
better part of a decade finally has to figure out which third-party libraries 
are breaking.

Python is better for some things, Go better for others.  Python makes a good 
first language; Go does not.  That affects numbers, too.  Go apps are MUCH 
simpler to deploy than Java or C# or Python apps, but that's going to matter 
more for enterprise users with a good release process than hobbyists or 
business users whose deploy is "scp a bunch of files over and reboot", which is 
more than you'd think, sadly.

I don't trust popularity metrics that treat vector quantities as scalars.  I'm 
not going to lose much sleep over this.


- Dave


> On Jan 15, 2020, at 8:16 PM, Liam  wrote:
> 
> That could affect the level of a term, but wouldn't impact its trend much. 
> Trends are the important insight of this graph.
> 
> On Wednesday, January 15, 2020 at 2:58:31 PM UTC-8, Robert Engels wrote:
> 
> Please look deeper into how these "trends" are calculated.
> 
> For example, if everyone that uses product Y can't figure out how feature X 
> works, and they search for it. Product Y will be showing growth...
> -Original Message- 
> From: Liam 
> Sent: Jan 15, 2020 4:18 PM 
> To: golang-nuts 
> Subject: [go-nuts] Re: Go mindshare is low & ~flat, per Google Trends 
> 
> My point is that Go should be rising, since Java & C# are falling. Python has 
> gained significant mindshare, and Go is way better.
> 
> I think something's amiss with the public perception of Go, but it's hard to 
> say what.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0C78DFFC-2A7D-4459-B347-8BAFF58AE104%40gmail.com.


[go-nuts] Re: How to query mongodb dynamically using Go interface

2020-01-16 Thread afriyie . abraham
Hi,

this is the JSON document in mongodb.
{
"sNssais": [{
"sst": 0,
"sd": "string"
}],
"nsiList": [
"string"
],
"ipv4Addresses": [
"198.51.100.1"
],
"ipv6Addresses": [
"2001:db8:85a3::8a2e:370:7334"
],
"amfInfo": {
"amfSetId": "string",
"taiList": [{
"plmnId": {
"mcc": "string",
"mnc": "string"
},
"tac": "3022",
"nid": "string"
}],
},
"customInfo": {}
}

The args in the *.tac are string values, even if i set the type casting 
like bson.M{"amfInfo.taiList.tac": args[0].(string)} it stiil do not match 
"3022" args input.
And yes, am looking for exact match.



On Thursday, January 16, 2020 at 5:04:40 PM UTC+2, Afriyie Abraham Kwabena 
wrote:
>
> Hi,
>
> I have been trying to create a dynamic mongodb query using golang 
> interface but the logical $or does not work.
> It only return a documents when the input matches the 
> bson.M{"sNssais.sst": args[0].(int32), "sNssais.sd": args[1].(string)}.
> other matches like bson.M{"amfInfo.taiList.tac": args}, etc does not work 
> even though a document in mongodb collection exist that matches the input 
> value.
> Any idea as how to do this? The function is as below
>
> func (m *NfInstanceDataAccess) FindIp(preferredNfInstances string, args 
> ...interface{}) ([]model.NfProfile, bool) {
> var ip []model.NfProfile
> pipeline := bson.M{
> "nfType": preferredNfInstances,
> "$or": []interface{}{
> bson.M{"sNssais.sst": args[0].(int32), "sNssais.sd": 
> args[1].(string)},
> bson.M{"amfInfo.taiList.tac": args},
> bson.M{"smfInfo.taiList.tac": args},
> bson.M{"upfInfo.taiList.tac": args},
> },
> }
> filter := bson.M{"ipv4Addresses": true}
> err := db.C(COLLECTION).Find(pipeline).Select(filter).All()
> if err != nil {
> return ip, false
> }
> return ip, true
> }
>
>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/37f74556-974f-4229-bd2f-6850bfa62620%40googlegroups.com.


Re: [go-nuts] Re: Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread Robert Engels
Well said. 

> On Jan 16, 2020, at 9:58 AM, Michael Jones  wrote:
> 
> 
> How global mindshare develops is something that I know quite a bit about 
> through leadership and engineering experience in multiple billion user 
> projects. 
> 
> One key lesson for me was that you reach a point where the audience you 
> originally wanted to serve (or refocused to serve) has been served. That’s 
> when the debate of “more for this group” or “something for other groups” 
> starts with vigor. 
> 
> There is a natural desire to grow but my advice here, after looking back 
> honestly, is that the way to move forward is to be so excellent at some 
> aspect(s) that users become effective missionaries. This is the only scaling 
> mechanism at scale (other than force in unusually controlled scenarios).
> 
> Looking forward (i.e. guessing) maybe Go needs new greatness in what it 
> already is and has by way of an “encyclopedia” of well-loved solutions. 
> Imagine a guide to 100 top uses with links to tools, samples for each, and 
> lots of details so that anyone wanting to build a static or dynamic web 
> server, ftp server, ssh client, mail processor, ... would have complete 
> guides from start to finish. 
> 
> Maybe existing solutions are sufficient or maybe they could be better. If 
> they have room for improvement then my guess is that this kind of beginner 
> hand holding might be the most effective investment for user growth. 
> 
> Just a guess,
> Michael
> 
>> On Thu, Jan 16, 2020 at 7:33 AM Amnon Baron Cohen  wrote:
>> Go was originally conceived as a niche language. And if it does what we 
>> need, then I don't think 
>> we need to be particularly bothered if other languages are more "popular".
>> 
>> But when looking at language popularity, I am not sure that the number of 
>> google searches is the most meaningful metric.
>> 
>> Lines of code on github could be more interesting.
>> 
>> FWIW: Githubs octoverse shows shows a 147% growth in Go usage last year.
>> 
>> And more interesting growth stats can be found on the Go blog 
>> https://blog.golang.org/8years
>> 
>> -- 
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/28b8066f-876b-41f6-b249-94dc4f255347%40googlegroups.com.
> -- 
> Michael T. Jones
> michael.jo...@gmail.com
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CALoEmQy-c1eH-bCH1vmTyMdf3_NMt31v6cWSdD8abha1OT%2BF%3Dw%40mail.gmail.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/07F3F0E3-3E3F-49CF-BFA2-C63E68AA9BFE%40ix.netcom.com.


Re: [go-nuts] Re: Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread Michael Jones
How global mindshare develops is something that I know quite a bit about
through leadership and engineering experience in multiple billion user
projects.

One key lesson for me was that you reach a point where the audience you
originally wanted to serve (or refocused to serve) has been served. That’s
when the debate of “more for this group” or “something for other groups”
starts with vigor.

There is a natural desire to grow but my advice here, after looking back
honestly, is that the way to move forward is to be so excellent at some
aspect(s) that users become effective missionaries. This is the only
scaling mechanism at scale (other than force in unusually controlled
scenarios).

Looking forward (i.e. guessing) maybe Go needs new greatness in what it
already is and has by way of an “encyclopedia” of well-loved solutions.
Imagine a guide to 100 top uses with links to tools, samples for each, and
lots of details so that anyone wanting to build a static or dynamic web
server, ftp server, ssh client, mail processor, ... would have complete
guides from start to finish.

Maybe existing solutions are sufficient or maybe they could be better. If
they have room for improvement then my guess is that this kind of beginner
hand holding might be the most effective investment for user growth.

Just a guess,
Michael

On Thu, Jan 16, 2020 at 7:33 AM Amnon Baron Cohen  wrote:

> Go was originally conceived as a niche language. And if it does what we
> need, then I don't think
> we need to be particularly bothered if other languages are more "popular".
>
> But when looking at language popularity, I am not sure that the number of
> google searches is the most meaningful metric.
>
> Lines of code on github could be more interesting.
>
> FWIW: Githubs octoverse shows shows a 147% growth in Go usage last year.
>
> And more interesting growth stats can be found on the Go blog
> https://blog.golang.org/8years
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/28b8066f-876b-41f6-b249-94dc4f255347%40googlegroups.com
> 
> .
>
-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CALoEmQy-c1eH-bCH1vmTyMdf3_NMt31v6cWSdD8abha1OT%2BF%3Dw%40mail.gmail.com.


Re: [go-nuts] Re: Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread Amnon Baron Cohen
Go was originally conceived as a niche language. And if it does what we 
need, then I don't think 
we need to be particularly bothered if other languages are more "popular".

But when looking at language popularity, I am not sure that the number of 
google searches is the most meaningful metric.

Lines of code on github could be more interesting.

FWIW: Githubs octoverse shows shows a 147% growth in Go usage last year.

And more interesting growth stats can be found on the Go blog 
https://blog.golang.org/8years

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/28b8066f-876b-41f6-b249-94dc4f255347%40googlegroups.com.


Re: [go-nuts] How to query mongodb dynamically using Go interface

2020-01-16 Thread burak serdar
On Thu, Jan 16, 2020 at 8:03 AM  wrote:
>
> Hi,
>
> I have been trying to create a dynamic mongodb query using golang interface 
> but the logical $or does not work.
> It only return a documents when the input matches the bson.M{"sNssais.sst": 
> args[0].(int32), "sNssais.sd": args[1].(string)}.
> other matches like bson.M{"amfInfo.taiList.tac": args}, etc does not work 
> even though a document in mongodb collection exist that matches the input 
> value.
> Any idea as how to do this? The function is as below

That depends on what's in args, and in amfInfo.taiList.tac, etc. args
is an array, so if the *.tac fields are also arrays, you're looking
for an exact match. Is that really the case?

>
> func (m *NfInstanceDataAccess) FindIp(preferredNfInstances string, args 
> ...interface{}) ([]model.NfProfile, bool) {
> var ip []model.NfProfile
> pipeline := bson.M{
> "nfType": preferredNfInstances,
> "$or": []interface{}{
> bson.M{"sNssais.sst": args[0].(int32), "sNssais.sd": 
> args[1].(string)},
> bson.M{"amfInfo.taiList.tac": args},
> bson.M{"smfInfo.taiList.tac": args},
> bson.M{"upfInfo.taiList.tac": args},
> },
> }
> filter := bson.M{"ipv4Addresses": true}
> err := db.C(COLLECTION).Find(pipeline).Select(filter).All()
> if err != nil {
> return ip, false
> }
> return ip, true
> }
>
>
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/c2dca0c6-e3f7-4822-9b7f-b09102450293%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqrOc%2BKzruMsbPF9JpCS59s7NQ%3DXjnsTQg-5vrgYs8id4Q%40mail.gmail.com.


[go-nuts] How to query mongodb dynamically using Go interface

2020-01-16 Thread afriyie . abraham
Hi,

I have been trying to create a dynamic mongodb query using golang interface 
but the logical $or does not work.
It only return a documents when the input matches the bson.M{"sNssais.sst": 
args[0].(int32), "sNssais.sd": args[1].(string)}.
other matches like bson.M{"amfInfo.taiList.tac": args}, etc does not work 
even though a document in mongodb collection exist that matches the input 
value.
Any idea as how to do this? The function is as below

func (m *NfInstanceDataAccess) FindIp(preferredNfInstances string, args 
...interface{}) ([]model.NfProfile, bool) {
var ip []model.NfProfile
pipeline := bson.M{
"nfType": preferredNfInstances,
"$or": []interface{}{
bson.M{"sNssais.sst": args[0].(int32), "sNssais.sd": 
args[1].(string)},
bson.M{"amfInfo.taiList.tac": args},
bson.M{"smfInfo.taiList.tac": args},
bson.M{"upfInfo.taiList.tac": args},
},
}
filter := bson.M{"ipv4Addresses": true}
err := db.C(COLLECTION).Find(pipeline).Select(filter).All()
if err != nil {
return ip, false
}
return ip, true
}



-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c2dca0c6-e3f7-4822-9b7f-b09102450293%40googlegroups.com.


[go-nuts] Re: [golang-dev] Do slice element modification operations check whether or not the modified elements are allocated on immutable zones?

2020-01-16 Thread T L
Glad to know this. Thanks for the info.

On Thu, Jan 16, 2020 at 8:35 AM Ralph Corderoy 
wrote:

> Hi Tapir,
>
> > Do slice element modification operations check whether or not the
> > modified elements are allocated on immutable zones?
> ...
> > //var Golang = strings.Join([]string{"Go", "lang"}, "") // not cause
> panicking
> > var Golang = "Golang"   // causes
> panicking
>
> Are you aware that memory pages may have permissions such as read-only,
> and that some data may be allocated to those pages?  Look up the address
> of the data in /proc/$pid/maps.
>
> I think this topic belongs on golang-nuts; reply-to set.
>
> --
> Cheers, Ralph.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAHbs%3DNbQ0Yp7sOuDSwmMoQucLRtiFnu4jCyCVHfWMnYRX7%2BF_w%40mail.gmail.com.


[go-nuts] Re: weak references

2020-01-16 Thread kirr
For the reference: 
https://godoc.org/lab.nexedi.com/kirr/neo/go/zodb/internal/weak
and rationale: 
https://lab.nexedi.com/kirr/neo/blob/cb94be39/go/zodb/connection.go#L73-121

Kirill


вторник, 5 марта 2013 г., 3:49:02 UTC+4 пользователь Dustin написал:
>
>
>   I've been looking around for some information on weak references and, 
> while I've found a few open threads, I haven't seen much of a closure on 
> this, nor an issue opened on the project. 
>
>   I'd like to have a weak reference.  It seems like this requires GC 
> cooperation, though I'm open to a supportable strategy that doesn't 
> require any core changes. 
>
>   A friendly irc user suggested something like this could theoretically 
> work:  http://play.golang.org/p/IHRU2TwgF9 
>
>   But in general, being able to build a map[thing]WeakReference would be 
> very useful for many caching scenarios.  WeakReference.Get() -> 
> interface{} would be fine.  Something typesafe would be even better. 
>
>   Is there a writeup about this?  Should I file an issue? 
>
> -- 
> dustin 
>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/79ec4b33-3130-4976-b0a7-7aea1d81b841%40googlegroups.com.


Re: [go-nuts] Re: Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread Ian Davis
If the purpose of adding "killer features" is just to make Go more popular then 
I'm completely against it. That doesn't seem like a sustainable way of growing 
and retaining a community, who may just move onto the next killer feature in 
another language. I'm not even sure that explicitly growing Go's attention 
should even be a goal. People will use Go when it fits the problems they need 
to solve.

I don't personally see any slowdown in Go's adoption in the areas I'm working 
in which is high scale web services. 

On Thu, 16 Jan 2020, at 11:12 AM, JuciÊ Andrade wrote:
> Liam has a point. Go is not attracting attention as it used to do. Go ceased 
> to generate news.
> 
> Other projects attracts attention by aggregating new features often. So there 
> is always a flux of news about the project, news that attracts interest, that 
> bring new users to the project. However, that approach ultimately leads to 
> disaster. Each new wave of developers want to employ the latest and greatest 
> features and after some years you end up with a nightmare in form of millions 
> of lines of source code using a plethora of competing techniques.
> 
> The minimalism in Go is its strength, but few people are mature enough to 
> appreciate that. So what now?
> 
> I think we need to add a killer feature now and then. Not so often as to 
> create a nightmare, but only a few, very sparse. Such a feature would be 
> something that is very desirable but utterly difficult to achieve, something 
> that only a selected group of the best professionals in the world backed by 
> one of the biggest tech companies in the world could make.
> 

> --
>  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.
>  To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/e14daa6c-b55b-43a4-9af8-f983057ba0ab%40googlegroups.com
>  
> .

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e18ab6a7-1c8b-44fc-a83c-d292d4befaf6%40www.fastmail.com.


Re: [go-nuts] Future of Error Formatting in the Standard Library

2020-01-16 Thread Sebastien Binet
On Sun, Jan 5, 2020 at 2:34 PM Joseph Lorenzini  wrote:

>
> Hi all,
>
>
> In the Go 2: Errors Proposal (issue 29934), a decision was made to defer
> error formatting changes and come up with a revised proposal for 1.14. I
> believe 1.14 is close to being release but I have not seen a proposal. I
> was curious if something is still in the works for this or whether this has
> been put on hold indefinitely.
>
> Asking because, it seems like something similar to what xerrors does with
> annotating and printing stack frames would be really useful in the standard
> lib for making go code in general easier to debug.
>
> https://github.com/golang/go/issues/29934#issuecomment-489682919
>

If I am not mistaken, this aspect of the errors proposal is in:
-  https://play.golang.org/p/T7w1Hc15JVZ

-s

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAAV3P_BfyceJFV85F%3DnXMnqXezqWjXdQSpBHCp_7Xb2j-7Vq%2BQ%40mail.gmail.com.


[go-nuts] Re: Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread JuciÊ Andrade
Liam has a point. Go is not attracting attention as it used to do. Go 
ceased to generate news.

Other projects attracts attention by aggregating new features often. So 
there is always a flux of news about the project, news that attracts 
interest, that bring new users to the project. However, that approach 
ultimately leads to disaster. Each new wave of developers want to employ 
the latest and greatest features and after some years you end up with a 
nightmare in form of millions of lines of source code using a plethora of 
competing techniques.

The minimalism in Go is its strength, but few people are mature enough to 
appreciate that. So what now?

I think we need to add a killer feature now and then. Not so often as to 
create a nightmare, but only a few, very sparse. Such a feature would be 
something that is very desirable but utterly difficult to achieve, 
something that only a selected group of the best professionals in the world 
backed by one of the biggest tech companies in the world could make.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e14daa6c-b55b-43a4-9af8-f983057ba0ab%40googlegroups.com.


[go-nuts] Re: [Proposal] database/sql: add interface that unite DB and Tx

2020-01-16 Thread Tamás Gulácsi
2020. január 16., csütörtök 8:20:17 UTC+1 időpontban Shulhan a következőt 
írta:
>
> ## Problem 
>
> At some point we have a function that receive an instance of database 
> connection to query rows in specific table. 
>
> Let's say that function F() accept DB that query table T. 
>
> If function F() called with DB instance, it will query only rows that has 
> been committed into database. 
>
> IF function F() called with Tx instance, it will query all rows including 
> the one that has not been committed yet into database. 
>
> Since DB and Tx are different types, we will have two functions that 
> almost have identical code, 
>
> func F(db *sql.DB) (output int) { 
>   q := `SELECT … FROM T WHERE …` 
>   err := db.QueryRow(q).Scan() 
>   … 
>   return output 
> } 
>
> func FWithTx(tx *sql.Tx)(output int) { 
>   q := `SELECT … FROM T WHERE …` 
>   err := tx.QueryRow(q).Scan() 
>   … 
>   return output 
> } 
>
>
> ## Proposed solution 
>
> Add an interface Session (the name is not fixed yet) to package sql with 
> the following signature, 
>
> type Session interface { 
> func Exec(query string, args ...interface{}) (Result, error) 
> func ExecContext(ctx context.Context, query string, args 
> ...interface{}) (Result, error) 
> func Prepare(query string) (*Stmt, error) 
> func PrepareContext(ctx context.Context, query string) (*Stmt, error) 
> func Query(query string, args ...interface{}) (*Rows, error) 
> func QueryContext(ctx context.Context, query string, args 
> ...interface{}) (*Rows, error) 
> func QueryRow(query string, args ...interface{}) *Row 
> func QueryRowContext(ctx context.Context, query string, args 
> ...interface{}) *Row 
> } 
>
> Session interface is combination of DB and Tx that contains all identical 
> methods. 
>
>
> ## Rationale 
>
> Without Session, user will have two functions that have the same code, 
>
> By using Session, we can minimise duplicate code in the user level. for 
> example using the previous problems definition the function F() become one, 
>
> func F(session sql.Session)(output int) { 
>   q := `SELECT … FROM T WHERE …` 
>   err := session.QueryRow().Scan() 
>   … 
>   return output 
> } 
>
>
> ## Discussion 
>
> Any thought about this proposal?



Just define the interface and use it - Go is not Java, iff a type 
statisfies an interface, then it also implements it!

You can use anonymous interfaces also!

```
func F(db interface { QueryRow() *sql.Row })(output int) { 
  q := `SELECT … FROM T WHERE …` 
  err := db.QueryRow().Scan(&
>
> output) 
>   … 
>   return output 
> } 

```

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a81bb8a1-bc68-487d-b678-dc3fd344e9ed%40googlegroups.com.