[go-nuts] Windows syscall.Open() change to fix os.Rename() & .Remove()

2019-07-10 Thread Liam
Microsoft recommends changing syscall.Open() for GOOS=windows to fix this. Pls reply if you know of existing apps that rely on it. This code fails with a "sharing violation" on Windows. That behavior is undocumented in package "os". path := "rename-after-open" fd, err := os.OpenFile(path,

Re: [go-nuts] Not receiving email digests

2019-07-10 Thread Ian Lance Taylor
On Wed, Jul 10, 2019 at 4:33 PM amr wrote: > > I appear to be no longer receiving the email digests daily. I last received a > daily on 26th June, and then a single daily on 2nd July. I tried leaving the > group and rejoining yesterday, to no avail! > Any ideas, please, moderator? Sorry, no

[go-nuts] Not receiving email digests

2019-07-10 Thread amr
I appear to be no longer receiving the email digests daily. I last received a daily on 26th June, and then a single daily on 2nd July. I tried leaving the group and rejoining yesterday, to no avail! Any ideas, please, moderator? -- You received this message because you are subscribed to the

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Burak Serdar
On Wed, Jul 10, 2019 at 3:24 PM Roman Kuprov wrote: > > Would the Context package not work for this issue? > (kinda new gopher here) It is similar to using a cancel channel. Context communicates the cancellation by closing a channel returned by Done(). > > On Wednesday, July 10, 2019 at 1:08:38

Re: [go-nuts] get interface and method name

2019-07-10 Thread Ian Lance Taylor
On Wed, Jul 10, 2019 at 1:40 PM Vasiliy Tolstov wrote: > > Hi! i have interface like > > type AccountService interface { > Create(context.Context) error > } > > if i need to get string representation of this interface from passed > AccountService.Create how can i do that? > > Now i create POC

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Roman Kuprov
Would the Context package not work for this issue? (kinda new gopher here) On Wednesday, July 10, 2019 at 1:08:38 PM UTC-6, Dan Eloff wrote: > > Yeah, agreed. I've been deep into concurrent programming for a long time > now, and into lock-free programming as well which is the most fraught kind

[go-nuts] get interface and method name

2019-07-10 Thread Vasiliy Tolstov
Hi! i have interface like type AccountService interface { Create(context.Context) error } if i need to get string representation of this interface from passed AccountService.Create how can i do that? Now i create POC like this: parts :=

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Dan Eloff
Yeah, agreed. I've been deep into concurrent programming for a long time now, and into lock-free programming as well which is the most fraught kind of programming I've ever done. Parallel is the future, it has been that way for a long time, but it's only getting more and more obvious. I think in

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Jesper Louis Andersen
On Wed, Jul 10, 2019 at 6:30 PM wrote: > > The best thing to do is to not use unmanaged resources. > Would be the Erlang solution. You cannot change the owner of an open file, and if the process owning it terminates, the file is closed. You can change ownership of a TCP socket, and then

Re: [go-nuts] Passing Struct from Go to C

2019-07-10 Thread Nitish Saboo
Hi Andrey, I made the following changes as suggested by you: InitStruct := C.calloc(1, C.sizeof_struct_Foo) InitStruct.key_value_cb = C.callOnMeGo_cgo InitStruct.data = C.int(1) C.initialize_engine(pattern_db, module_path, (*C.Foo)(unsafe.Pointer(InitStruct))) Still Getting following error:

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Jesper Louis Andersen
On Wed, Jul 10, 2019 at 6:45 PM Dan Eloff wrote: > On Wed, Jul 10, 2019 at 7:54 AM Michael Jones > wrote: > >> unbuffered means nothing is sent until is is simultaneously received, so >> there is no limbo or race or uncertainty. one sender "wins" the select and >> the others remain blocked

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Burak Serdar
On Wed, Jul 10, 2019 at 10:45 AM Dan Eloff wrote: > > On Wed, Jul 10, 2019 at 7:54 AM Michael Jones wrote: >> >> unbuffered means nothing is sent until is is simultaneously received, so >> there is no limbo or race or uncertainty. one sender "wins" the select and >> the others remain blocked

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Dan Eloff
On Wed, Jul 10, 2019 at 7:54 AM Michael Jones wrote: > unbuffered means nothing is sent until is is simultaneously received, so > there is no limbo or race or uncertainty. one sender "wins" the select and > the others remain blocked waiting. > So I'm correct then: "Now one of two things must

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread jake6502
On Tuesday, July 9, 2019 at 12:27:32 PM UTC-4, Dan Eloff wrote: > > I couldn't use <-channel.Close since in my case the goroutine isn't > guaranteed to have something sent, so that would leak goroutines. I added a > cleanup goroutine to scan timed-out channels and close them, which solves >

Re: [go-nuts] Passing Struct from Go to C

2019-07-10 Thread andrey mirtchovski
the Go "Callback" struct may have completely different size and alignment than the C.Foo one expected by C.initialize_engine. therefore you want to construct the C version when calling C.initialize_engine, and the Go version for everything else. Your call may look something like this: initStruct

Re: [go-nuts] Include tests in binary and run them

2019-07-10 Thread Tamás Gulácsi
2019. július 10., szerda 6:43:39 UTC+2 időpontban Farid Zakaria a következőt írta: > > That's not bad and good to know. > Thanks for sharing ! > > Fundamentally I want to include the tests in the main though executable > and then run testing.T myself in the normal main > (Through a CLI command)

[go-nuts] Re: With Go modules, is that possible to reference a package which hasn't gotten a module support

2019-07-10 Thread Tamás Gulácsi
2019. július 10., szerda 11:00:48 UTC+2 időpontban Roman Gomoliako a következőt írta: > > thepudds, > > Thank you for the reply, thanks for the link! > > The follow-up question, what if the project isn't hosted anywhere yet? > Like, I have a module-opted package and it tries to use a local >

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Michael Jones
unbuffered means nothing is sent until is is simultaneously received, so there is no limbo or race or uncertainty. one sender "wins" the select and the others remain blocked waiting. On Wed, Jul 10, 2019 at 6:24 AM Dan Eloff wrote: > Maybe I'm wrong here in my understanding of unbuffered

[go-nuts] Re: Include tests in binary and run them

2019-07-10 Thread Sean Liao
actually looking into it more since *_test,go files aren't included in a normal build you are probably better off just writing your tests as normal functions if you want them included in the final build -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Dan Eloff
Maybe I'm wrong here in my understanding of unbuffered channels, but I don't think so: Matt says earlier: "Only a buffered channel can "hold" anything. If the channel is unbuffered, then you are guaranteed that another goroutine has at least received the item you sent when the send statement

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Dan Eloff
> > If the channel is unbuffered, there are two parties, S and R (Sender and > Receiver). If the channel is buffered, it is another party, C (channel). > The delivery chain is really S -> C -> R. Whereas in the unbuffered case, > rendezvous means an atomic exchange of the resource (S -> R).

Re: [go-nuts] Include tests in binary and run them

2019-07-10 Thread Sean Liao
I think testing.MainStart() does what you want though do nore the caveats https://golang.org/pkg/testing/#MainStart -- 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

[go-nuts] Re: Announcing a Go API for YottaDB

2019-07-10 Thread tptan12345
Hi Bhaskar, > I have a problem when I *go get lang.yottadb.com/go/yottadb* There is an error: "*could not determine kind of name for C.ydb_call_variadic_plist_func_st*" Did I miss any step? I am looking forward to your answer. Thanks. -- You received this message because you are

Re: [go-nuts] Build kubernetes with gollvm

2019-07-10 Thread Yuan Ting
Thank you, I will continue to pay attention to it. Hope those bugs can be solved :) Thank you again for your patience. On Wednesday, July 10, 2019 at 7:56:03 PM UTC+8, Than McIntosh wrote: > > OK, thanks for checking on that. > > Sounds like this is a new problem (not too surprising, since

Re: [go-nuts] Include tests in binary and run them

2019-07-10 Thread Marko Ristin-Kaufmann
Hi Farid, If I understood your question correctly, you can play with build flags. Alternatively, you can add a "-diagnostics" flag. Consider also design-by-contract with contracts tested at run time (e.g., we use our own implementation https://github.com/Parquery/gocontracts; see also other

Re: [go-nuts] Build kubernetes with gollvm

2019-07-10 Thread 'Than McIntosh' via golang-nuts
OK, thanks for checking on that. Sounds like this is a new problem (not too surprising, since this is an area of the compiler that is undergoing a lot of changes in recent weeks; tip is a bit unstable). I have my hands full with a couple of other bugs that I am juggling right now; filed issue

Re: [go-nuts] Passing Struct from Go to C

2019-07-10 Thread andrey mirtchovski
what i do is have a similar struct in Go, and the original C one. here 'callbacks' is the go one, and "type Engine C.struct_cl_engine" is the opaque C one: https://github.com/mirtchovski/clamav/blob/master/callback.go#L63 On Wed, Jul 10, 2019 at 5:25 AM Nitish Saboo wrote: > > Hi Andrey, > > I

Re: [go-nuts] Avoiding resource leaks with racing channels

2019-07-10 Thread Jesper Louis Andersen
On Tue, Jul 9, 2019 at 6:14 AM Daniel Eloff wrote: > If a select statement has multiple channels ready when it runs, then it > will choose one at a random. So if you fire something across a channel that > holds a resource, like an open file descriptor - you have no guarantees > that the other

Re: [go-nuts] Passing Struct from Go to C

2019-07-10 Thread Nitish Saboo
Hi Andrey, I understand the issue here but how can I pass a callback function in a struct to C code.I need a struct because I want to pass and an extra parameter 'userdata' as well that I would require back as part of callback. Thanks, Nitish On Wed, Jul 10, 2019 at 4:39 PM andrey mirtchovski

Re: [go-nuts] Passing Struct from Go to C

2019-07-10 Thread andrey mirtchovski
i don't think you can use a go function directly in the callback. you need a correctly-typed C helper to do it. at least that used to be the case. see examples: https://github.com/mirtchovski/clamav/blob/master/cfuncs.go https://github.com/mirtchovski/clamav/blob/master/callback.go -- You

Re: [go-nuts] Passing Struct from Go to C

2019-07-10 Thread Nitish Saboo
Hi Tamas, I made it *C.Foo but still getting the error. main.go === type Callback struct { Func func(*C.char , *C.char , C.size_t, C.int) UserData int32 } Calling C code in the following manner = C.initialize_engine(pattern_db, module_path,

[go-nuts] Re: With Go modules, is that possible to reference a package which hasn't gotten a module support

2019-07-10 Thread Roman Gomoliako
thepudds, Thank you for the reply, thanks for the link! The follow-up question, what if the project isn't hosted anywhere yet? Like, I have a module-opted package and it tries to use a local module-unaware package. For a local module-aware package usage one would use `replace` declaration.

Re: [go-nuts] Passing Struct from Go to C

2019-07-10 Thread Tamás Gulácsi
*C.foo -- 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

[go-nuts] Re: On the topic of try() and errors

2019-07-10 Thread pierre . curto
Interesting reasoning Michael... Le mercredi 10 juillet 2019 01:46:03 UTC+2, Michael Jones a écrit : > > In the hope of elevating the discussion of late, I've made a little speech > as one might do at a lunchtime discussion with students or colleagues. > Maybe this will make sense to some

Re: [go-nuts] Passing Struct from Go to C

2019-07-10 Thread Nitish Saboo
Hi, Looks like I was able to resolve the C error.I am getting the following Go error while running 'make' command: gcc -L/usr/local/lib -lsyslog-ng -o syslog-node.so -L/usr/local/lib/syslog-ng -ldbparser -c `pkg-config --libs --cflags glib-2.0` -I/usr/local/include/syslog-ng/

[go-nuts] Passing Struct from Go to C

2019-07-10 Thread Nitish Saboo
Hi, I am trying to pass a Struct from Go to C (this is cgo).I m passing a callback function in that struct that will be called from C code to Go. main.go === type Callback struct { Func func(*C.char , *C.char , C.size_t, C.int) UserData int32 } Calling C code in the following manner