[go-nuts] Is it safe to close a channel once more in this way ?

2016-12-13 Thread P Q
func close_safe(c chan bool) { select { case <-c: default: close(c) } } Closing a channel onece more can be a controversial topic, sometimes it is useuful. I saw the code to close a closed channel. I thought the code looked nice at first, but could become errernous. Let's assume that two goruti

[go-nuts] Re: How many bytes binary.Write write before an error?

2016-12-15 Thread P Q
2016년 12월 16일 금요일 오전 11시 5분 53초 UTC+9, Peng Wang 님의 말: > > Actually I don't really care about that, just don't want break the > interface requirement > in the doc it says "WriteAt writes len(p) bytes from p to the underlying > data stream at offset off. It returns the number of bytes written from

[go-nuts] Re: How many bytes binary.Write write before an error?

2016-12-15 Thread P Q
2016년 12월 16일 금요일 오전 11시 5분 53초 UTC+9, Peng Wang 님의 말: Actually I don't really care about that, just don't want break the interface requirement in the doc it says "WriteAt writes len(p) bytes from p to the underlying data stream at offset off. It returns the number of bytes written from p (0 <=

[go-nuts] why does runtime.GOMAXPROCS act like getter and setter?

2016-12-23 Thread P Q
runtime.GOMAXPROCS(n) behaves in two ways: getter if n < 1, otherwise setter. For setter, does runtime.SetGOMAXPROCS(n) look good? The only reason behind current behavior is the function is rarely used? -- You received this message because you are subscribed to the Google Groups "golang-nuts

[go-nuts] Accessing an slice is too slow than Array

2017-01-05 Thread P Q
I measured how long it takes to access an element on array in three ways: array, slice, unsafe.Pointer https://play.golang.org/p/Ofz3u8_AZe BenchmarkArray : 500025.7 ns/op BenchmarkSlice : 200059.1 ns/op BenchmarkPointer: 3 6.85 ns/op BenchmarkC : 2

[go-nuts] Re: Is this a compiler bug?

2017-01-06 Thread P Q
Using inherent print function, you can see this more clearly: https://play.golang.org/p/WKk7n9U2zt -- 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+un

[go-nuts] cgo: undefined reference to `stdout'

2016-07-31 Thread P Q
https://play.golang.org/p/4XZSmyRkZa I've got error message when building the code as follows: C:\Users\Home\AppData\Local\Temp\go-build437760086\command-line-arguments\_obj\_cgo_main.o:_cgo_main.c:(.data+0x0): undefined reference to `stdout' collect2.exe: error: ld returned 1 exit status I do