Re: [go-nuts] How to determine the correct method signature to override fopen

2017-11-03 Thread Ian Lance Taylor
On Fri, Nov 3, 2017 at 5:44 PM, wrote: > > Thanks Ian. I had included that because it seems required in order for me to > refer to the return type (C.FILE) and so I can access the underlying C.fopen > function. This is the approach I have with open but perhaps this is >

Re: [go-nuts] Re: appengine golang logs

2017-11-03 Thread Sankar P
I knew about this package. I mentioned about this in my mail itself :-) I wanted a different way as it is not always possible to replace "log" calls in all the existing code. Some libraries need to be used in binaries which will be deployed outside appengine. They should not have a dependency on

Re: [go-nuts] How to determine the correct method signature to override fopen

2017-11-03 Thread tonywalker . uk
This is without the include: $ go build -buildmode=c-shared # github.com/walkert ./main.go:6:41: could not determine kind of name for C.FILE ./main.go:7:8: could not determine kind of name for C.fopen -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] How to determine the correct method signature to override fopen

2017-11-03 Thread tonywalker . uk
Thanks Ian. I had included that because it seems required in order for me to refer to the return type (C.FILE) and so I can access the underlying C.fopen function. This is the approach I have with open but perhaps this is different. If I'm not supposed to use the include, can you advise how I

Re: [go-nuts] Expected ambigiuous reference error, got a value instead

2017-11-03 Thread Jan Mercl
On Fri, Nov 3, 2017 at 11:04 PM Daniel Skinner wrote: > https://play.golang.org/p/Y1UxMgNhWx > > I ran into this today but don't understand why the compiler isn't throwing an ambiguous reference error. Maybe I've misunderstood why this error is thrown the few times I've seen it.

[go-nuts] Expected ambigiuous reference error, got a value instead

2017-11-03 Thread Daniel Skinner
https://play.golang.org/p/Y1UxMgNhWx I ran into this today but don't understand why the compiler isn't throwing an ambiguous reference error. Maybe I've misunderstood why this error is thrown the few times I've seen it. -- You received this message because you are subscribed to the Google

[go-nuts] How to determine the correct method signature to override fopen

2017-11-03 Thread tonywalker . uk
Hi, I've been writing a shared-object which I'll use via LD_PRELOAD to override the open syscall. This is currently working OK but now I want to move on to fopen. I've defined it (as far as I can tell) in-line with the stdio header see here . However, when

Re: [go-nuts] is this code thread safety?

2017-11-03 Thread Drew Derbyshire
What Jan said. I had started my own post before I realize other sane people checked in about the absurd colors. On Thursday, November 2, 2017 at 3:13:07 AM UTC-7, Jan Mercl wrote: > > On Thu, Nov 2, 2017 at 6:54 AM sheepbao > wrote: > > > the close function is thread

[go-nuts] Re: When should a RoundTripper close its connection?

2017-11-03 Thread Frits van Bommel
The best way is probably to replace the Response.Body before returning the result of http.ReadResponse() with an io.ReadCloser that also closes the underlying channel. Replace the end of RoundTrip() with something like this (untested) code: resp := http.ReadResponse(bufio.NewReader(ch),

Re: [go-nuts] how could a new user konw which packge should be used?

2017-11-03 Thread Ian Lance Taylor
On Thu, Nov 2, 2017 at 11:16 PM, 517 March wrote: > as a new Go programmer, > how could I know which package should be use? > > is there any search tool could be used? > > or does it just depend on your experience? There is a search tool at https://godoc.org. Ian --

[go-nuts] Re: Go vendoring question

2017-11-03 Thread Bobby M.
Speaking as a new Gopher, but I have had lots of experience with software dependencies. A tool like dep would be perfect for this. You could simply pin the one dependency until a fix is provided for the error, and for the others you can simply keep updating to the latest. This may not be the

[go-nuts] Re: appengine golang logs

2017-11-03 Thread Jim Cote
In appengine you have to use google.golang.org/appengine/log package. The log calls must have a context passed to it. See https://cloud.google.com/appengine/docs/standard/go/logs/reference. On Friday, November 3, 2017 at 3:58:34 AM UTC-4, Sankar wrote: > > Hi > > > I have a golang file where

Re: [go-nuts] is this code thread safety?

2017-11-03 Thread 'Bryan Mills' via golang-nuts
In general you can use the race detector to help answer this sort of question, although it does not detect all races. Unfortunately, it doesn't detect this one. (I've filed https://golang.org/issue/22569, because I think it should.) On Friday, November 3, 2017 at 4:08:19 AM UTC-4, sheepbao

Re: [go-nuts] How to know if interface{} data is nil w/o reflecting?

2017-11-03 Thread ojucie
This thread helped me to understand better the current scenario and the implications of a future change. I would be glad to recognize if this conversation had changed my mind, but it didn't. Some programmers discovered that they could use this "valid nil interface" to do some smart tricks, as

Re: [go-nuts] cgo style question

2017-11-03 Thread Andy Balholm
Use the arr1 style when the length of the C array is known at compile time, and the arr2 style when it’s not known till runtime. Andy > On Nov 3, 2017, at 9:18 AM, DV wrote: > > Which "style" of wrapping a C array in a Go slice is more idiomatic in this > code -

[go-nuts] cgo style question

2017-11-03 Thread DV
Which "style" of wrapping a C array in a Go slice is more idiomatic in this code - https://play.golang.org/p/6EbKl22MPQ - "arr1" or "arr2"? They both seem to produce the exact same result. I've seen the "arr2" style more often, but I don't understand why. The way I wrapped "arr1" seems more

[go-nuts] how could a new user konw which packge should be used?

2017-11-03 Thread Tamás Gulácsi
Use the standard library. -- 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

[go-nuts] how could a new user konw which packge should be used?

2017-11-03 Thread 517 March
as a new Go programmer, how could I know which package should be use? is there any search tool could be used? or does it just depend on your experience? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

[go-nuts] Issue with log.V and log.${Level}Depth

2017-11-03 Thread Xiaoyi Shi
Hi there, When combining V() and ${Level}Depth() together, the logging logic becomes less clear. For instance, with the retry function below: ```go func Retry(fn func() error) error { var lastErr error for attempt := 0; attempt < maxRetries; attempt++ { backoff.Sleep(attempt) if

Re: [go-nuts] How to know if interface{} data is nil w/o reflecting?

2017-11-03 Thread Jakob Borg
I often do nil checks on interfaces in places like constructors that may or may not have received optional parameters. In some cases as a parameter that may be nil if no implementation is required, in some cases where a functional option setting the interface was not given. Typically this looks

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2017-11-03 Thread ojucie
Yes, Ayan, you are quite correct. There are a lot of comparisons to check if an error is nil. It has it's own FAQ entry: https://golang.org/doc/faq#nil_error Sincerely, what I am after is an example of a situation where the solution proposed by Dave Cheney would create a problem, like "See

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2017-11-03 Thread Ayan George
On 11/03/2017 05:23 AM, oju...@gmail.com wrote: > Could somebody please point me to any example of comparing an > interface to nil, in production code? Thanks. > Does checking if a variable of type error is nil count? -ayan -- You received this message because you are subscribed to the

[go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2017-11-03 Thread ojucie
Could somebody please point me to any example of comparing an interface to nil, in production code? 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

Re: [go-nuts] is this code thread safety?

2017-11-03 Thread sheepbao
Thanks, I got it. On Friday, November 3, 2017 at 11:26:31 AM UTC+8, Jesse McNelis wrote: > > On Thu, Nov 2, 2017 at 4:54 PM, sheepbao > wrote: > > > > the close function is thread safety? how about call `closed` at the same > > time. > > It's not safe. Multiple

[go-nuts] appengine golang logs

2017-11-03 Thread Sankar
Hi I have a golang file where I have code like: log.Fatal("My error message: ", err) When the above statement is executed, In the appengine logviewer, I get something like: panic: os.Exit called goroutine 1 [running]: os.Exit(0x1) go/src/os/proc.go:58