Re: [go-nuts] lock for assigning to different elements of an array

2017-08-02 Thread Dave Cheney
I'm not really sure what you are asking. I think your second paragraph got eaten by autocorrect at the critical point. Could try maybe asking your question in a different way? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-02 Thread Henrik Johansson
How should I know when it is safe to omit using locks? What I have drilled into my head is "yes you not only need a lock but every read of shared data has to have a corresponding write that uses a lock". Lock meaning anything that results in the proper memory effects. I can sort of get that this

[go-nuts] look for a example: call a DLL's function on Windows by CGO

2017-08-02 Thread Fino
yesterday I just found that, the syscall way to use DLL on Windows cannot use float32 as parameters, so I am look for a example: call a DLL's function on Windows in the CGO way, the DLL is not Windows' own DLL, but a third-party DLL which have a lot of double parameters, thanks in

[go-nuts] Re: gobind generated constructor for struct containing []byte sometimes corrupts data

2017-08-02 Thread Antonio Marcedone
My intuition above seems to contrast with https://godoc.org/golang.org/x/mobile/cmd/gobind: Avoid reference cycles > The language bindings maintain a reference to each object that has been > proxied. When a proxy object becomes unreachable, its finalizer reports > this fact to the object's

[go-nuts] Re: gobind generated constructor for struct containing []byte sometimes corrupts data

2017-08-02 Thread Antonio Marcedone
I am not sure I understand what is going on here. For reference, the relevant code is: String s = "This is a test string"; MyStruct struct = new MyStruct(s.getBytes("UTF-8")); //struct.setE(s.getBytes("UTF-8")); tv.append("\nFirst time: "+ new

[go-nuts] Re: gobind generated constructor for struct containing []byte sometimes corrupts data

2017-08-02 Thread amarcedone via golang-nuts
I am not sure I understand what is going on here. For reference, the relevant code is: String s = "This is a test string"; MyStruct struct = new MyStruct(s.getBytes("UTF-8")); //struct.setE(s.getBytes("UTF-8")); tv.append("\nFirst time: "+ new

[go-nuts] lock for assigning to different elements of an array

2017-08-02 Thread Dave Cheney
No, but anything reading from that array which is not the original writer will have to coordinate via a lock or channel to ensure a proper happens before relationship exists. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

[go-nuts] gobind generated constructor for struct containing []byte sometimes corrupts data

2017-08-02 Thread Elias Naur
[]byte arguments are passed by reference, not copied. You need to copy any byte slices you retain after the function or method call. - elias -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-02 Thread Ian Lance Taylor
On Wed, Aug 2, 2017 at 2:12 PM, rabiee via golang-nuts wrote: > > Do we need a lock for assigning to different elements of an array while > running parallel functions? No. Ian -- You received this message because you are subscribed to the Google Groups

[go-nuts] lock for assigning to different elements of an array

2017-08-02 Thread rabiee via golang-nuts
Hi All, Do we need a lock for assigning to different elements of an array while running parallel functions? For example is lock needed in the following code or not. var rm sync.Mutex var ts [2]stringfor i, s := range []string{"first", "second"} { i, s := i, s go func(){

Re: [go-nuts] Re: HTTP/2 multiplexing

2017-08-02 Thread James Abley
A goroutine making each request, passing in the http.Client should work. Something like http://blog.narenarya.in/concurrent-http-in-go.html On Wed, 2 Aug 2017 at 18:58 wrote: > Parallel in the sense of HTTP/2 multiplexing, i.e. sending the next > request without having

Re: [go-nuts] How to judge error in golang?

2017-08-02 Thread Ian Lance Taylor
On Wed, Aug 2, 2017 at 11:36 AM, yihao yang wrote: > > I found it is very difficult to judge an error in golang. For example, if I > want to judge a specific error returned by a function, but sometimes the > error is just newed by errors.New(xxx). > In those situations,

Re: [go-nuts] How to judge error in golang?

2017-08-02 Thread Jakob Borg
On 2 Aug 2017, at 20:40, yihao yang wrote: > > What is the philosophy in golang error? I also saw a lot of packages have > their own Error override error interface. Why there is no shared Error > structure with a shareable error code? > > 在 2017年8月2日星期三

[go-nuts] Re: How to judge error in golang?

2017-08-02 Thread yihao yang
What is the philosophy in golang error? I also saw a lot of packages have their own Error override error interface. Why there is no shared Error structure with a shareable error code? 在 2017年8月2日星期三 UTC-7上午11:36:11,yihao yang写道: > > Hi, > > I found it is very difficult to judge an error in

[go-nuts] How to judge error in golang?

2017-08-02 Thread yihao yang
Hi, I found it is very difficult to judge an error in golang. For example, if I want to judge a specific error returned by a function, but sometimes the error is just newed by errors.New(xxx). In those situations, should I just compare the error string to know what's the exact error? Is that a

Re: [go-nuts] Re: GO Vs D

2017-08-02 Thread Michael Jones
If I was unclear...I do not mean that Go is the ultimate answer to those questions, or that D (or whatever) is the anthesis of them. I wish Go was different in various ways too. On Wed, Aug 2, 2017 at 8:39 AM, wrote: > I'm still not convinced that using a language which

[go-nuts] Re: Problems buildding go from source, tests "hangs"

2017-08-02 Thread 'Bryan C. Mills' via golang-nuts
What is the output of `$(go env CC) --version` on your machine?` On Wednesday, August 2, 2017 at 8:31:37 AM UTC-4, SauliusGurklys wrote: > > Hi, > > while building go from source: > > cd /usr/local/src/go > ./clean.bash > ./all.bash > > build succeeds without any problem and then when tests are

[go-nuts] Re: HTTP/2 multiplexing

2017-08-02 Thread pala . daniele
Parallel in the sense of HTTP/2 multiplexing, i.e. sending the next request without having to wait for the reply of the previous one. -- 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

Re: [go-nuts] Problems buildding go from source, tests "hangs"

2017-08-02 Thread Ian Lance Taylor
On Wed, Aug 2, 2017 at 5:17 AM, SauliusGurklys wrote: > > while building go from source: > > cd /usr/local/src/go > ./clean.bash > ./all.bash > > build succeeds without any problem and then when tests are started then they > just "hangs" > > ... > # ../misc/cgo/testplugin >

[go-nuts] Re: HTTP/2 multiplexing

2017-08-02 Thread Tamás Gulácsi
Parallel, on the same connection? How? Which byte shall be sent next? TCP is essentially sequential, sorry. -- 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] [ANN] Gokoban - 3D Puzzle Game written in Go!

2017-08-02 Thread Ian Lance Taylor
On Mon, Jul 31, 2017 at 6:04 PM, Daniel Salvadori wrote: > Hi everyone, > > I made an open-source 3D puzzle game with Go. It's called Gokoban > ! > You control the Go gopher, and your objective in each level is to push > the boxes until

Re: [go-nuts] Re: GO Vs D

2017-08-02 Thread eric . pelzer
I'm still not convinced that using a language which is especially limited by design always helps in implementing the simplest solution, that will be the easiest to maintain. Maybe it's the case most of the time, but from my personal experience, you can only get that result by using the right

Re: [go-nuts] Re: GO Vs D

2017-08-02 Thread Michael Jones
I've often found it helpful to consider extreme limit cases. In solo/school/hobby programming, you code and test more than you debug and you understand intent implicitly because you are coding it as you go. As a professional at work, as part of a team, in a code review regime, using third-party

Re: [go-nuts] Ellipse use error

2017-08-02 Thread Ian Lance Taylor
On Wed, Aug 2, 2017 at 6:30 AM, Mandolyte wrote: > This line of code: > retrTarget := path.Join(maindir, ss[0], pathparts[npp:]...) > > produces this error: > .\xxx.go:131: too many arguments in call to path.Join > have (string, string, []string...) > want

Re: [go-nuts] Background reader in an HTTP server's connection serving loop

2017-08-02 Thread Ian Lance Taylor
On Wed, Aug 2, 2017 at 5:55 AM, Konstantin Khomoutov wrote: > > The "conn" type from net/http/server.go, in its serve() method contains > a "for" loop which is supposed -- as I understand it -- to keep reading > requests from the connected socket if the client wished to reuse the

Re: [go-nuts] Socket Priority affect Read Deadline?

2017-08-02 Thread Konstantin Khomoutov
On Wed, Aug 02, 2017 at 05:41:15AM -0700, jlu@gmail.com wrote: > I wrapped some code to do listen UDP port and set priority, like this > > func ListenUDP(t string, laddr *net.UDPAddr, priority int) (*net.UDPConn, > error) { > conn, err := net.ListenUDP(t, laddr) [...] > err =

[go-nuts] Re: Go one-line installer

2017-08-02 Thread mhhcbon
Hi, As you at this kind of work, have you considered a reliable one-liner to install dependencies ? I got that own, just today, from a gae repo (?), anyways here it is, go get -u -v $(go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep -v

[go-nuts] Re: Socket Priority affect Read Deadline?

2017-08-02 Thread Dave Cheney
http://godoc.org/net#UDPConn.File "The returned os.File's file descriptor is different from the connection's. Attempting to change properties of the original using this duplicate may or may not have the desired effect." On Wednesday, 2 August 2017 23:34:16 UTC+10, jlu...@gmail.com wrote: > >

[go-nuts] Socket Priority affect Read Deadline?

2017-08-02 Thread jlu . xzp
Hi guys, I wrapped some code to do listen UDP port and set priority, like this func ListenUDP(t string, laddr *net.UDPAddr, priority int) (*net.UDPConn, error) { conn, err := net.ListenUDP(t, laddr) if err != nil { return nil, err } if priority < 0 { return

[go-nuts] Ellipse use error

2017-08-02 Thread Mandolyte
This line of code: retrTarget := path.Join(maindir, ss[0], pathparts[npp:]...) produces this error: .\xxx.go:131: too many arguments in call to path.Join have (string, string, []string...) want (...string) Easy to work around, but I don't understand why it doesn't work...

[go-nuts] Re: Go one-line installer

2017-08-02 Thread Igor Maznitsa
I also had interest for such installer about year ago and developed mvn-golang plugin (which can download and install go sdk and tune environment during build process) but it works in maven environment of course -- You received this message because you

Re: [go-nuts] Go one-line installer

2017-08-02 Thread roger peppe
On 2 August 2017 at 12:16, Jan Mercl <0xj...@gmail.com> wrote: > On Wed, Aug 2, 2017 at 12:47 PM Florin Pățan wrote: > >> I would never put anyone to the trouble of compiling Go themselves, so >> it's not clear why you are suggesting that. > > From where comes the

Re: [go-nuts] xml namespaces - encoding ok, decoding result not ok

2017-08-02 Thread roger peppe
It seems to me like your unmarshaling isn't actually working (look inside the decoded data). Here's an alternative version: https://play.golang.org/p/CAChEa4-Kp It's still not exactly right, as the DID tag is in the empty namespace in the original XML, but is in os.xsd.v1 in the encoded version.

[go-nuts] Background reader in an HTTP server's connection serving loop

2017-08-02 Thread Konstantin Khomoutov
The "conn" type from net/http/server.go, in its serve() method contains a "for" loop which is supposed -- as I understand it -- to keep reading requests from the connected socket if the client wished to reuse the connection. That loop reads the request's header and then starts a background

[go-nuts] Problems buildding go from source, tests "hangs"

2017-08-02 Thread SauliusGurklys
Hi, while building go from source: cd /usr/local/src/go ./clean.bash ./all.bash build succeeds without any problem and then when tests are started then they just "hangs" ... # ../misc/cgo/testplugin PASS something # ../misc/cgo/testasan # ../misc/cgo/testsanitizers after this

Re: [go-nuts] Go one-line installer

2017-08-02 Thread Jan Mercl
On Wed, Aug 2, 2017 at 12:47 PM Florin Pățan wrote: > I would never put anyone to the trouble of compiling Go themselves, so it's not clear why you are suggesting that. >From where comes the assumption that it's a trouble? I was not suggesting anything, but while we are

Re: [go-nuts] xml namespaces - encoding ok, decoding result not ok

2017-08-02 Thread Marcin Jurczuk
Here is fully working/not working/not working example with whole SOAP envelope I'm getting from server: If I use different structs for encoding/decoding it works. https://play.golang.org/p/hVzB0lh2WH Change line: rx := new(SOAPEnvelope2) to: rx := new(SOAPEnvelope) And you will get error

Re: [go-nuts] Go one-line installer

2017-08-02 Thread Florin Pățan
On Wednesday, August 2, 2017 at 11:34:33 AM UTC+1, Jan Mercl wrote: > > On Wed, Aug 2, 2017 at 12:27 PM Florin Pățan > wrote: > > > I speak from the experience of trying to help people get Go running on > Linux, macOS and Windows, this is a terribly frustrating step and

[go-nuts] Re: GO Vs D

2017-08-02 Thread Egon
Yes, I would agree -- the type declarations won't bother you in real-world, because when they become unreadable, then you would use additional types to clarify them... in any language. *And, I have nothing against either languages -- I used D in my BSc thesis and Go in my MSc thesis.* The

Re: [go-nuts] Re: GO Vs D

2017-08-02 Thread ecstatic . coder
As I said, it's not because something sophisticated exists in a language that you have to use it. It's quite the opposite. But indeed, with Go you don't have the problem, because these features were removed from the language to avoid the temptation to use them. I can understand that, because

Re: [go-nuts] Go one-line installer

2017-08-02 Thread Jan Mercl
On Wed, Aug 2, 2017 at 12:27 PM Florin Pățan wrote: > I speak from the experience of trying to help people get Go running on Linux, macOS and Windows, this is a terribly frustrating step and unknown for most of them. Please share what's frustrating and not clear about the

[go-nuts] Re: Go one-line installer

2017-08-02 Thread Florin Pățan
On Wednesday, August 2, 2017 at 3:14:07 AM UTC+1, Steve Francia wrote: > > On Tuesday, August 1, 2017 at 7:49:32 PM UTC-4, Florin Pățan wrote: >> >> Hi, >> >> The idea is good but: >> - it needs to modify the path to add GOROOT/bin and GOPATH/bin to it >> > It does. If it didn't do this you've

Re: [go-nuts] Go one-line installer

2017-08-02 Thread Florin Pățan
On Wednesday, August 2, 2017 at 1:37:48 AM UTC+1, Tyler Compton wrote: > > > I was quite happy that the era of executable "installers" died once we > > got package managers. > > This seems to come from a purely Linux perspective. I suspect that people > who use Linux are quite a bit less likely

[go-nuts] Re: GO Vs D

2017-08-02 Thread ecstatic . coder
Ok I understand you now. Maybe I'm biased because I like both languages, but I'm not convinced that this example illustrates well Go's simplicity compared to D. For 99% of my *personal* daily use of both languages, very honestly, I've never felt that using types, functions, arrays, etc etc was

Re: [go-nuts] xml namespaces - encoding ok, decoding result not ok

2017-08-02 Thread Konstantin Khomoutov
On Tue, Aug 01, 2017 at 10:48:23AM -0700, Marcin Jurczuk wrote: > Your example is returning xml that is wrong from system I'm talking to. > My SOAP service requires tags in few different namespaces. > My code returns: > > * * > > Your code returns: > > ** [...] > > >

Re: [go-nuts] Re: GO Vs D

2017-08-02 Thread Chris Hopkins
On Wednesday, 2 August 2017 09:46:08 UTC+1, ecstati...@gmail.com wrote: > > And btw, this doesn't mean that just because there are genericity and > polymorphism in D, that I must use them. > > No, but the person reading your code must understand them. Not only that but they must understand

[go-nuts] Re: GO Vs D

2017-08-02 Thread Egon
The example contained 3 versions, C, D and Go. function pointer tables aren't that uncommon, maybe the []error part is uncommon Examples from real world code: https://github.com/egonelbre/fedwiki/blob/master/action.go#L59

[go-nuts] Re: GO Vs D

2017-08-02 Thread Doğan Kurt
Let's not make it personal. I personally respect walter bright and andrei alexandrescu a lot and because of a very dear friend of mine , i started fiddling with D as early as 2010. Surely it's a great leap forward from C++. But someone who comes from a language as small

Re: [go-nuts] Re: "fallthrough statement out of place" in `if` block inside `swicth` block

2017-08-02 Thread Doğan Kurt
In first snippet, i didn't get the second if. cond1 is true anyway. Second snippet is equivalent to if (cond1) { do_stuff() do_other_stuff() } else if cond2 { do_other_stuff() } which is more straightforward than using fallthrough imo. On Wednesday, August 2, 2017 at 9:03:35 AM

[go-nuts] Re: GO Vs D

2017-08-02 Thread ecstatic . coder
Still waiting the Go version of this very useful D code... I'm not asking you to browse the web to find to find most complex declaration you can ever do in D, Go or C++ for instance. I've never used such ridiculous code in my Go/D/C++/Java/C# applications, and neither will you. I'm just

Re: [go-nuts] Reasoning behind behavior of range, when index is maintained

2017-08-02 Thread Christoph Berger
Good point. The same is true for the C-style for loop BTW. https://play.golang.org/p/58jwveiywB Using an explicit boolean flag for signaling success avoids this trap. > On 2. Aug 2017, at 10:30, tom.pa...@centralway.com wrote: > > A side effect of this approach is that the index after the

Re: [go-nuts] Re: GO Vs D

2017-08-02 Thread ecstatic . coder
And btw, this doesn't mean that just because there are genericity and polymorphism in D, that I must use them. Most of the time, I don't even need to use them, like in Go, so I simply don't use them. What I'm saying is that, sometimes, you have to apply a similar function to different types

Re: [go-nuts] Re: Go one-line installer

2017-08-02 Thread Henrik Johansson
At home on my Arch i really prefer pacman for everything and only as a last resort do I ever exec any curlable installer. The problem is usually that they don't get properly updated and the packagemanager anyway pulls in Go since it is a dependency for something else and it is a mess with two or

[go-nuts] Re: GO Vs D

2017-08-02 Thread Egon
On Wednesday, 2 August 2017 10:51:43 UTC+3, ecstati...@gmail.com wrote: > > For all the common parts with Go (functions, methods, reference classes, > strings, arrays, slices, ranges, foreach, etc), honestly I don't know why > you say it's simpler in Go. > > Can you show me two examples of code

Re: [go-nuts] Reasoning behind behavior of range, when index is maintained

2017-08-02 Thread tom . payne
A side effect of this approach is that the index after the range loop will be zero if slice contains zero or one elements: https://play.golang.org/p/F7lLZ5wcuv This means that code using the index after the range will need to re-test whether the slice was empty to avoid a potential panic. On

[go-nuts] Re: GO Vs D

2017-08-02 Thread ecstatic . coder
For all the common parts with Go (functions, methods, reference classes, strings, arrays, slices, ranges, foreach, etc), honestly I don't know why you say it's simpler in Go. Can you show me two examples of code side by side, and tell me "look how much simpler it's with Go's" ? Because from

Re: [go-nuts] Re: GO Vs D

2017-08-02 Thread Wojciech S. Czarnecki
On Tue, 1 Aug 2017 05:04:24 -0700 (PDT) ecstatic.co...@gmail.com wrote: > But D also gives you reference classes, genericity, function polymorphism, > conditional compilation, design by contract assertions, compile-time meta > programming, All things above to be avoided in _maintainable_

Re: [go-nuts] Re: Go one-line installer

2017-08-02 Thread Aram Hăvărneanu
> most Linux users are used to setting environment variables and > installing from tarballs. No, most Linux users are used to installing from package managers. Unless you were referring to installing Go in particular, where I conjecture that most Linux users who don't use some package manager to

Re: [go-nuts] Re: "fallthrough statement out of place" in `if` block inside `swicth` block

2017-08-02 Thread Konstantin Khomoutov
On Tue, Aug 01, 2017 at 05:54:28AM -0700, kultigin@gmail.com wrote: > i believe you should avoid fallthrough statement except for auto-generated > code. > > it's obscure what you are trying to accomplish with that piece of code, but > surely you can do it in a better way. They have its