Re: [go-nuts] Single instance of program

2016-10-04 Thread Justin Israel
A unix domain socket seems reliable since the OS will clean it up for you regardless of how your application terminates. Justin On Wed, Oct 5, 2016 at 9:30 AM 'Ingo Oeser' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Are you looking for something like > https://godoc.org/github.com/

[go-nuts] Cookies lose data when round tripped through net/http/cookiejar.Jar

2016-10-04 Thread Nate Finch
See here: https://play.golang.org/p/E4_8NiodmK Is this intended? The cookies returned from cookiejar.Jar.Cookies() don't include the domain, which is part of the key that they're stored under, so they're no longer "the same" cookies. -- You received this message because you are subscribed to

[go-nuts] Re: Cannot decode encrypted private key

2016-10-04 Thread 高橋誠二
sorry, referenced line was wrong. https://github.com/golang/crypto/blob/master/ssh/keys.go#L772 2016年10月5日水曜日 3時07分45秒 UTC+9 高橋誠二: > > https://github.com/golang/crypto/blob/master/ssh/keys.go#L751 > > This line blocks to parse private key, that encrypted and contains the > encryption header. > Bu

[go-nuts] Re: overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread Dave Cheney
bt, to serialise a structure with encoding/json or encoding/xml (and anything else which uses reflect) the fields have to be public (start with a capital letter) anyway, so that breaks the deadlock with keywords of the same name. On Wednesday, 5 October 2016 02:54:32 UTC+11, David Luu wrote

Re: [go-nuts] overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread Dan Kortschak
On Mon, 2016-10-03 at 23:32 -0700, David Luu wrote: > type runKeywordReturnType struct{ > return interface{} > status string > output string > error string > traceback string > } > > Seems to not work since return and error are go keywords. You can't do so with return, but error is not

[go-nuts] unsafe horror: introspecting chans

2016-10-04 Thread Dan Kortschak
I am thinking about adding the capacity to dump the contents of chans to the utter package[1]. The code to do this is relatively straightforward[2], though it messes about with unsafe aliasing of runtime types in nasty ways. One thing that I'm not sure of is the locking that is required (I expect

Re: [go-nuts] go closure escape analysis

2016-10-04 Thread thebrokentoaster
Example 1 is a known issue: https://github.com/golang/go/issues/7714 In fact your example is identical to the one Keith presented. On Tuesday, October 4, 2016 at 8:54:02 AM UTC-7, Chris Manghane wrote: > > In example1, the // BAD: y escapes is there because y should not escape > from that functi

Re: [go-nuts] Single instance of program

2016-10-04 Thread 'Ingo Oeser' via golang-nuts
Are you looking for something like https://godoc.org/github.com/nightlyone/lockfile ? -- 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...@goo

Re: [go-nuts] Single instance of program

2016-10-04 Thread Dave Cheney
Not directly, but a system wide mutex can be built on top of sysv semaphores, files on disk, or an open tcp or unix domain socket. As this lock would be system wide, the main consideration is to ensure that it is _always_ unlocked when the owning process dies for any reason. Then that just leav

Re: [go-nuts] Single instance of program

2016-10-04 Thread dc0d
I had the same question tonight! On Windows (using C#) I just create a Named Mutex, which is system wide. One of values that it returns identifies that if the mutex is already created by other instance, or it's the first time it's being created on this system. Is there something similar on Linu

[go-nuts] Re: Using atomics for close checks

2016-10-04 Thread adonovan via golang-nuts
On Tuesday, 4 October 2016 13:32:03 UTC-4, Ahmed (OneOfOne) W. wrote: > > Some of our code uses something like: > > type Dummy struct { > closed int64 > } > > func(d *Dummy) IsClosed() bool { > return atomic.LoadInt64(&d.closed) == 1 > } > > func(d *Dummy) Close() error { > if !atomic.CompareAndSwa

[go-nuts] Re: Using atomics for close checks

2016-10-04 Thread Roberto Zanotto
A goroutine might try to Close while another is checking IsClosed, it is racy no matter how you implement it. Go with the atomic load. On Tuesday, October 4, 2016 at 7:32:03 PM UTC+2, Ahmed (OneOfOne) W. wrote: > > Some of our code uses something like: > > type Dummy struct { > closed int64 > } >

[go-nuts] Cannot decode encrypted private key

2016-10-04 Thread 高橋誠二
https://github.com/golang/crypto/blob/master/ssh/keys.go#L751 This line blocks to parse private key, that encrypted and contains the encryption header. But is this necessary? So much keys maybe encrypted and this disturbs to authenticate client for ssh connection in many cases. It should alert

[go-nuts] Using atomics for close checks

2016-10-04 Thread Ahmed (OneOfOne) W.
Some of our code uses something like: type Dummy struct { closed int64 } func(d *Dummy) IsClosed() bool { return atomic.LoadInt64(&d.closed) == 1 } func(d *Dummy) Close() error { if !atomic.CompareAndSwapInt64(&d.closed, 0, 1) { return fmt.Errorf("already closed") } // other logic return nil }

Fwd: [go-nuts] Correct use of Mutex

2016-10-04 Thread Pietro Gagliardi
> Begin forwarded message: > > From: Pietro Gagliardi > Subject: Re: [go-nuts] Correct use of Mutex > Date: October 3, 2016 at 4:22:34 PM EDT > To: a...@cpu.host > > Why are you locking on the map key? > >> On Oct 3, 2016, at 2:53 PM, a...@cpu.host wrote: >> >> >> Whi

Fwd: [go-nuts] overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread Pietro Gagliardi
> Begin forwarded message: > > From: Pietro Gagliardi > Subject: Re: [go-nuts] overriding keywords or rather allowing them to be part > of a struct in go? > Date: October 4, 2016 at 12:59:54 PM EDT > To: David Luu > > Assuming the XML-RPC package uses it, the documentation for encoding/xml w

Re: [go-nuts] Re: overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread David Luu
I was just about to mention that part about struct tags thing, where I've seen it used for JSON marshaling/unmarshaling. I'm new to go, so still learning. Where can I find more details on that feature (in general)? It's already built-in for use with XML? Or does one have to implement the parsin

Re: [go-nuts] Re: overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread Konstantin Khomoutov
On Tue, 4 Oct 2016 08:54:32 -0700 (PDT) David Luu wrote: > >> Why do you care? > > I personally wouldn't but a (test framework) protocol built on top of > XML-RPC that I want to interface to expects the following response > back: > > > > > > return [...] > and the only

[go-nuts] Re: overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread David Luu
>> Why do you care? I personally wouldn't but a (test framework) protocol built on top of XML-RPC that I want to interface to expects the following response back: return 42 status PASS output

Re: [go-nuts] go closure escape analysis

2016-10-04 Thread 'Chris Manghane' via golang-nuts
In example1, the // BAD: y escapes is there because y should not escape from that function, but the current algorithm needs to be improved for this case. In that closure, the address of y is captured as the closure argument p and since p is only dereferenced, the analysis should not consider it to

Re: [go-nuts] SWIG and anonymous field inheritance

2016-10-04 Thread Shengqiu Li
Another advantage is when we use multiple inheritance. Currently we can only use SwigGetTheSecondBase() method to manually convert an object into a parent other than the first one, however if we use the embedded field, it means we can store the bases' pointers in the struct and we don't need m

Re: [go-nuts] Slow compile times

2016-10-04 Thread Nick Craig-Wood
On 04/10/16 09:27, rene.zbin...@gmail.com wrote: > I use the following packages in a test file: > > import ( > "testing" > > "github.com/coreos/etcd/clientv3" > "github.com/coreos/etcd/integration" > "github.com/coreos/pkg/capnslog" > ) > > > Now I have the problem, that I have really slow compile

Re: [go-nuts] Re: How to initialize all members of a slice

2016-10-04 Thread ahmed . momena
Thank you guys for helping me out. The problem was not with "string" type members, it was "bool" type. I wanted to set the default as true if it was not present in the input. Without using unmarshallJSON, I have no way of setting it, right? On Monday, October 3, 2016 at 9:28:49 PM UTC-5, Lars Sei

Re: [go-nuts] SWIG and anonymous field inheritance

2016-10-04 Thread Shengqiu Li
> > Does it pass the SWIG testsuite? > No. I have only done some initial works. The other parts, for example the director feature are not modified yet. I think one of the biggest advantages is that it can shorten the wrapper code. When C++ inheritance hierarchy is large and deep, the wrapper

Re: [go-nuts] SWIG and anonymous field inheritance

2016-10-04 Thread Ian Lance Taylor
On Tue, Oct 4, 2016 at 7:07 AM, Shengqiu Li wrote: > I have made a preliminary demo using the anonymous field feature > github.com/dontpanic92/swig This is written in a way that I find hard to understand--I can't easily see the differences between the old code and the new. Does it pass the SWIG

Re: [go-nuts] overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread Konstantin Khomoutov
On Mon, 3 Oct 2016 23:32:17 -0700 (PDT) David Luu wrote: > Say I wanted to define a struct like this: > > type runKeywordReturnType struct{ > return interface{} > status string > output string > error string > traceback string > } > > Seems to not work since return and error are go ke

[go-nuts] Re: looking for a hot reloader/producer package

2016-10-04 Thread Egon
On Tuesday, 4 October 2016 16:23:05 UTC+3, mhh...@gmail.com wrote: > > On Tuesday, October 4, 2016 at 1:55:56 PM UTC+2, Egon wrote: >> >> On Tuesday, 4 October 2016 14:11:03 UTC+3, mhh...@gmail.com wrote: >>> >>> Hi! >>> >>> I m not sure to get why you say 2-4 is not worthy. >>> >>> Is it because

Re: [go-nuts] SWIG and anonymous field inheritance

2016-10-04 Thread Shengqiu Li
I have made a preliminary demo using the anonymous field feature github.com/dontpanic92/swig After wrapping your example C++ code, the following Go code acts the same as C++ code: package main import "test5" func test(a test5.A) { a.M1() } func main() { b := test5.NewB() test(b)

Re: [go-nuts] SWIG and anonymous field inheritance

2016-10-04 Thread Shengqiu Li
What I mean is that the difference doesn't affect the wrapper. Your example shows the situation of purely go code, but the wrapper code doesn't purely go code -- although the "path" are different, the destination is the same. If your code acts as a wrapper -- let's say that A.m2 will call test_A

Re: [go-nuts] `go test` does not honor -ldflags

2016-10-04 Thread Art Mellor
Perhaps documenting the behavior is the best quick fix. Not knowing how 'main' gets altered - is it something that is predictable? If so, I don't think it is too terrible to document that so you can alter your command line appropriately. I personally use the feature to pass in build numbers an

Re: [go-nuts] SWIG and anonymous field inheritance

2016-10-04 Thread Ian Lance Taylor
On Tue, Oct 4, 2016 at 6:33 AM, Shengqiu Li wrote: > Thanks for your reply. In my view, the difference seems not affect the > behavior. As we store the pointer of the C++ object, when we call a C++ > virtual function in Go and the object itself is an instance of child class, > calling the parent's

Re: [go-nuts] `go test` does not honor -ldflags

2016-10-04 Thread Ian Lance Taylor
On Tue, Oct 4, 2016 at 6:03 AM, Art Mellor wrote: > From a user experience standpoint, I think the "Principle of least > astonishment" would argue it is more of a bug than not > https://en.wikipedia.org/wiki/Principle_of_least_astonishment I can't argue with that. The problem is that the definit

Re: [go-nuts] SWIG and anonymous field inheritance

2016-10-04 Thread Shengqiu Li
Thanks for your reply. In my view, the difference seems not affect the behavior. As we store the pointer of the C++ object, when we call a C++ virtual function in Go and the object itself is an instance of child class, calling the parent's function or the child's function are the same -- finall

Re: [go-nuts] overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread Ian Lance Taylor
On Mon, Oct 3, 2016 at 11:32 PM, David Luu wrote: > > Say I wanted to define a struct like this: > > type runKeywordReturnType struct{ > return interface{} > status string > output string > error string > traceback string > } > > Seems to not work since return and error are go keywords.

Re: [go-nuts] overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread 'chris dollin' via golang-nuts
On 4 October 2016 at 07:32, David Luu wrote: > Say I wanted to define a struct like this: > > type runKeywordReturnType struct{ > return interface{} > status string > output string > error string > traceback string > } > > Seems to not work since return and error are go keywords. If I ca

[go-nuts] Re: looking for a hot reloader/producer package

2016-10-04 Thread mhhcbon
On Tuesday, October 4, 2016 at 1:55:56 PM UTC+2, Egon wrote: > > On Tuesday, 4 October 2016 14:11:03 UTC+3, mhh...@gmail.com wrote: >> >> Hi! >> >> I m not sure to get why you say 2-4 is not worthy. >> >> Is it because it seems there is no generic implementation of such >> behavior ? >> > > I've

Re: [go-nuts] `go test` does not honor -ldflags

2016-10-04 Thread Art Mellor
>From a user experience standpoint, I think the "Principle of least astonishment" would argue it is more of a bug than not https://en.wikipedia.org/wiki/Principle_of_least_astonishment -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscri

[go-nuts] function signature question regarding pointers and arrays

2016-10-04 Thread David Luu
http://www.gorillatoolkit.org/pkg/rpc defines a particular method implementation to have to satisfy this type of argument signature: The method has three arguments: *http.Request, *args, *reply but the argument type can be anything beyond that for args & reply (so it seems). So if args and/or

[go-nuts] overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread David Luu
Say I wanted to define a struct like this: type runKeywordReturnType struct{ return interface{} status string output string error string traceback string } Seems to not work since return and error are go keywords. If I capitalize the first letter, that works. But say I really wanted to

[go-nuts] gomobile - detect OS information

2016-10-04 Thread Scot Newberry
I'm evaluating gomobile and building a simple application just display a text both with OS name (Android, or iOS), OS release... I browse through the documents in https://godoc.org/golang.org/x/mobile but can't find out how to get those informations. So, are those informations available in gomo

[go-nuts] Slow compile times

2016-10-04 Thread rene . zbinden
Hi I use the following packages in a test file: import ( "testing" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/integration" "github.com/coreos/pkg/capnslog" ) Now I have the problem, that I have really slow compile times (up to 10 seconds instead of 1-2 seconds). I know for nor

[go-nuts] Re: looking for a hot reloader/producer package

2016-10-04 Thread Egon
On Tuesday, 4 October 2016 14:11:03 UTC+3, mhh...@gmail.com wrote: > > Hi! > > I m not sure to get why you say 2-4 is not worthy. > > Is it because it seems there is no generic implementation of such behavior > ? > I've written 3-6 hot reloaders, and I've yet to stumble on a "great general purp

[go-nuts] Re: looking for a hot reloader/producer package

2016-10-04 Thread mhhcbon
Hi! I m not sure to get why you say 2-4 is not worthy. Is it because it seems there is no generic implementation of such behavior ? Which leads to costly copy pastes. Or some side effects that may occur and which make it to difficult to maintain to even attempt to write it ? I made a new vers

[go-nuts] Re: Go locking and channels much slower than Java equivalent, program spends most of time in sync.(*Mutex).Lock() and sync.(*Mutex).Unlock()

2016-10-04 Thread sphilippov
Try spinlocks instead of mutexes: https://github.com/pi/goal/blob/master/gut/spinlock.go -- 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...@