Re: [go-nuts] windows syscall (*LazyProc).Call Why the returned error is always non-nil?

2017-10-17 Thread Dave Cheney
Please raise an issue https://golang.org/issue/new On Wednesday, 18 October 2017 16:06:28 UTC+11, bronze man wrote: > > I already found this bug yesterday. > I am thinking why not golang team just fix this bug by change code? > It looks easier to fix this bug then to document this bug. > > On

Re: [go-nuts] windows syscall (*LazyProc).Call Why the returned error is always non-nil?

2017-10-17 Thread bronze man
I already found this bug yesterday. I am thinking why not golang team just fix this bug by change code? It looks easier to fix this bug then to document this bug. On Tuesday, October 17, 2017 at 11:59:42 AM UTC+8, Ian Lance Taylor wrote: > > On Mon, Oct 16, 2017 at 8:17 PM, bronze man

[go-nuts] Re: How to pass a value to multiple readers of a shared channel

2017-10-17 Thread Sokolov Yura
Following is a dangerous error-prone technique. If you use it in you program, most likely you have a hidden bug, that will appear in high concurrency situation. ``` func wait(c chan T) T { v := <-c c <- v; return v; } ``` I had proposal for future primitive:

[go-nuts] Re: Make error handling less verbose with Zig %% operator and %return expression?

2017-10-17 Thread prades . marq
Personally it's not a verbosity issue but a readability issue 99% of the time. if go fmt would just keep the whole if statement on a single line it would already alleviate some of the pain of having to read a codebase ridden with error handling code. if foo,err = DoIO();err!=nil{return

[go-nuts] Re: Make error handling less verbose with Zig %% operator and %return expression?

2017-10-17 Thread 'Bryan Mills' via golang-nuts
There are lots of similar proposals in the issue tracker. Of those, https://golang.org/issue/21161 seems to have the most traffic. On Tuesday, October 17, 2017 at 5:09:33 PM UTC-4, Nicolas Grilly wrote: > > I just read about Zig, a new programming language designed to replace C. > > The error

[go-nuts] Re: Compile-time parameters in Zig: a possible solution to generic functions and data structures in Go?

2017-10-17 Thread 'Bryan Mills' via golang-nuts
On Tuesday, October 17, 2017 at 4:52:55 PM UTC-4, Nicolas Grilly wrote: > > Hello, > > I just read about the concept of compile-time parameters in Zig (a new > programming language designed to replace C): > > >

Re: [go-nuts] Panic recovery and mutex lock question

2017-10-17 Thread Ian Lance Taylor
On Tue, Oct 17, 2017 at 5:03 PM, wrote: > > I was wondering if the code ever panics and we have a if recover := > recover(); recover != nil { > > in a defer func and we are using sync.RWMutexes which do not have a defer to > unlock for example. > > What kinds of things can

[go-nuts] Panic recovery and mutex lock question

2017-10-17 Thread davidrenne
Hi there, I was wondering if the code ever panics and we have a if recover := recover(); recover != nil { in a defer func and we are using sync.RWMutexes which do not have a defer to unlock for example. What kinds of things can happen if the code unexpectedly panics when we are in a Lock()

[go-nuts] Re: Cross compiled binary caches goroot?

2017-10-17 Thread Dave Cheney
On Tuesday, 17 October 2017 14:59:30 UTC+11, Nate Finch wrote: > > So I figured out I was looking for the error in the wrong place. The > place it was failing was in go/types when it tries to parse the files, > using the go/build.Default context. Which is created here: >

[go-nuts] Re: Do closures cons?

2017-10-17 Thread Juliusz Chroboczek
> Depends on what your profiling is telling you. The trouble is -- I have no idea what is the impact of small allocations. I've managed to eliminate most useless large allocations (the amount of data consed used to be twice the amount of data processed, it's now on the order of 103%), which has

Re: [go-nuts] How to run (individual) tests and benchs of the stdlib?

2017-10-17 Thread Ian Lance Taylor
On Tue, Oct 17, 2017 at 2:43 PM, wrote: > > I was wondering how to run tests and benchmarks of the Go standard library > such as this one: > https://go-review.googlesource.com/c/go/+/44730/4/src/crypto/tls/handshake_server_test.go#1056 > > $ pwd >

[go-nuts] Re: Do closures cons?

2017-10-17 Thread Juliusz Chroboczek
> A method value, on the other hand, will allocate memory in some cases, > as it may need to hold a copy of the value whose method will be > invoked. Even if the method takes a pointer receiver? -- Juliusz -- You received this message because you are subscribed to the Google Groups

[go-nuts] How to run (individual) tests and benchs of the stdlib?

2017-10-17 Thread google
I was wondering how to run tests and benchmarks of the Go standard library such as this one: https://go-review.googlesource.com/c/go/+/44730/4/src/crypto/tls/handshake_server_test.go#1056 $ pwd $GOPATH/src/github.com/golang/go/src/crypto/tls $ git rev-parse HEAD

[go-nuts] Implementing futures with channels [was: How to pass a value...]

2017-10-17 Thread Juliusz Chroboczek
> The answer depends on whether you have just one value or many. For a single > value (sometimes known as a "future"), I tend to pair a chan of struct{} > with a value to be set. To make the value available, set it, then close the > channel. Readers wait on the channel, then read the value.

[go-nuts] Make error handling less verbose with Zig %% operator and %return expression?

2017-10-17 Thread Nicolas Grilly
I just read about Zig, a new programming language designed to replace C. The error handling philosophy is very similar to Go: control flow in general and error handling in particular is explicit. Zig has even a defer statement inspired by Go ;-) I noticed that Zig provides a %% operator and

[go-nuts] Compile-time parameters in Zig: a possible solution to generic functions and data structures in Go?

2017-10-17 Thread Nicolas Grilly
Hello, I just read about the concept of compile-time parameters in Zig (a new programming language designed to replace C): http://andrewkelley.me/post/zig-programming-language-blurs-line-compile-time-run-time.html Could it be a way to provide generic functions and data structures in Go? I

[go-nuts] [ANN] seshcookie - sessions stored in HTTP cookies

2017-10-17 Thread Bobby Powers
I had originally written seshcookie pre-Go1. I've recently updated the library to work with Contexts, use AES-GCM for simpler authenticated encryption, and improved the tests. https://github.com/bpowers/seshcookie Let me know if you see anything you think can be improved or removed! yours,

Re: [go-nuts] Do closures cons?

2017-10-17 Thread Ian Lance Taylor
On Tue, Oct 17, 2017 at 11:50 AM, Juliusz Chroboczek wrote: > > I was about to do something like that: > > var p *P > ... > otherpackage.f(func(data []byte) { > a := p.x + p.y * 42 + p.someothercomplicatedstuff > p.g(data, a) > } > > (Yeah, I know.

Re: [go-nuts] accept4: too many open files;

2017-10-17 Thread lee
This is 1.9.1 and I had not thought of switching to http2 although do need to maintain the 1.1 for older clients. The closing of the body could explain it though which I thought was automatic on a return from the handlers? Do I need to explicitly call that in the handlers?? -- You received

[go-nuts] Do closures cons?

2017-10-17 Thread Juliusz Chroboczek
I was about to do something like that: var p *P ... otherpackage.f(func(data []byte) { a := p.x + p.y * 42 + p.someothercomplicatedstuff p.g(data, a) } (Yeah, I know. I dislike callbacks too, but I'm pretty much stuck in this particular case since Go doesn't do

Re: [go-nuts] repeatable builds

2017-10-17 Thread roger peppe
Have you looked at the dep tool (github.com/golang/dep) ? On 17 Oct 2017 13:42, "Conrad Wood" wrote: > Hi, > > We're considering Go for new services in our software architecture. > Generally it seems like a good fit. There are a few things I'm not sure > about though, so I

Re: [go-nuts] accept4: too many open files;

2017-10-17 Thread Shawn Milochik
What version of Go are you using? Have you tried HTTP/2? The only thing that jumps out at me is that r.Body() is never closed. -- 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,

[go-nuts] accept4: too many open files;

2017-10-17 Thread lee
I have the following code which was working fine in test but in live I am getting 500 errors reported to the clients with multiple lines of 2017/10/17 15:44:52 http: Accept error: accept tcp [::]:9090: accept4: too many open files; retrying in 1s 2017/10/17 15:44:53 http: Accept error: accept

[go-nuts] Re: Task scheduler as a library?

2017-10-17 Thread Alex Buchanan
> > > Having tried using things like gleam/glow (see > https://github.com/chrislusf/gleam) and dask (which has similar ideas but > written in python) it sounds like a FIFO work stealing type scheduler > wouldn't be a bad idea. In particular dask's approach is quite nicely put > together.

Re: [go-nuts] nil maps

2017-10-17 Thread 'Thomas Bushnell, BSG' via golang-nuts
Here's a case that comes up for me: type table map[string]map[string]string func (t table) add(x, y, z string) { if t[x] == nil { t[x] = make(map[string]string) } t[x][y] = z } func (t table) get(x, y string) string { return t[x][y] } The fact that t[x] can be indexed even if it

[go-nuts] Re: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-17 Thread john
just a heads up regarding Ubuntu Bash Shell on Windows10: if you open the Ubuntu Bash Shell and type the command: "*lsb_release -a" *you might discover it is running Ubuntu 14.04 you might want to run an upgrade to Ubuntu 16.04 which is now available. See the following for installation

Re: [go-nuts] Re: How to pass a value to multiple readers of a shared channel

2017-10-17 Thread Jesper Louis Andersen
If you have serious performance needs, then something like the "Disruptor" pattern is useful. There are ports of that from Java to Go out there, but I don't know how stable or useful they are. The Disruptor pattern is to keep a circular ring-buffer of elements. The writer and each reader keeps

[go-nuts] Re: Multi line go generate vs Bash script

2017-10-17 Thread gplus
Hi Michał, Do the second and third line(s) depend on the success of the previous one(s)? If so, a Bash script seems a good option as it allows you to stop the whole process if one step fails. If you are not a fan of Bash or of makefiles, or if you don't want to restrict yourself to systems

[go-nuts] Re: Perfomance - sha256 Encoding to Hex

2017-10-17 Thread 詹青朋
Maybe you can try this https://github.com/minio/sha256-simd 在 2017年10月17日星期二 UTC+8下午4:13:41,Christian LeMoussel写道: > > I need to calculate 10 millions of sha256 checksums, > > Actually I do this : > > var bl int > var pnb = make([]byte, 10) > var hash = [32]byte > var sha256Hash string > var

[go-nuts] repeatable builds

2017-10-17 Thread Conrad Wood
Hi, We're considering Go for new services in our software architecture. Generally it seems like a good fit. There are a few things I'm not sure about though, so I wonder what others do: 1. How does one ensure repeatable builds? (go get obviously pulls from the internet by default.to get

[go-nuts] Re: Perfomance - sha256 Encoding to Hex

2017-10-17 Thread Christian LeMoussel
OK, I'm new in GO. As you indicate I will profiling by writing a standard testing.B benchmark. 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

[go-nuts] Re: Perfomance - sha256 Encoding to Hex

2017-10-17 Thread gary . willoughby
There are syntax errors in your code. On Tuesday, 17 October 2017 09:13:41 UTC+1, Christian LeMoussel wrote: > > I need to calculate 10 millions of sha256 checksums, > > Actually I do this : > > var bl int > var pnb = make([]byte, 10) > var hash = [32]byte > var sha256Hash string > var steps =

Re: [go-nuts] Re: perfs of a Go binary VS C++

2017-10-17 Thread Michael Jones
yes On Tue, Oct 17, 2017 at 3:47 AM, Sebastien Binet wrote: > hi, > > (thanks for having a look at this) > > On Tue, Oct 17, 2017 at 6:01 AM, mura wrote: > >> Hi, >> >> A sequential read with `dd if=f64s.root of=/dev/null bs=32` takes around >> 8.5 secs

Re: [go-nuts] Re: perfs of a Go binary VS C++

2017-10-17 Thread Sebastien Binet
hi, (thanks for having a look at this) On Tue, Oct 17, 2017 at 6:01 AM, mura wrote: > Hi, > > A sequential read with `dd if=f64s.root of=/dev/null bs=32` takes around > 8.5 secs (10.4 secs using read-data.go) on my machine. It would even take > up to 55 secs when bs = 1.

[go-nuts] Re: How to pass a value to multiple readers of a shared channel

2017-10-17 Thread st ov
that's an great article thank you! On Sunday, October 15, 2017 at 6:51:03 PM UTC-7, dja...@gmail.com wrote: > > This post might help: > > https://rogpeppe.wordpress.com/2009/12/01/concurrent-idioms-1-broadcasting-values-in-go-with-linked-channels/ > > Djadala > > On Sunday, October 15, 2017 at

[go-nuts] Perfomance - sha256 Encoding to Hex

2017-10-17 Thread Dave Cheney
The answer to your question is to profile your function. You can do this by writing a standard testing.B benchmark which will give you access to Go’s profiling tools more or less for free. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Perfomance - sha256 Encoding to Hex

2017-10-17 Thread Christian LeMoussel
I need to calculate 10 millions of sha256 checksums, Actually I do this : var bl int var pnb = make([]byte, 10) var hash = [32]byte var sha256Hash string var steps = 1000 startBench := time.Now() for i := 0; i < steps; i++ { bl = 0 bl += copy(pnb[bl:], "TEST") bl +=

Re: [go-nuts] nil maps

2017-10-17 Thread Rob Pike
A nil map is like a regular map but it has nothing in it, cannot grow, and takes zero space. -rob On Tue, Oct 17, 2017 at 5:31 PM, Christian Himpel wrote: > The spec defines: "A nil map is equivalent to an empty map except that no > elements may be added."

[go-nuts] Re: Task scheduler as a library?

2017-10-17 Thread Jimmy Tang
On Monday, 16 October 2017 01:53:25 UTC+1, Alex Buchanan wrote: > > Not a spanner at all. > > I think the Task Execution Schemas (TES) [1], which Funnel is based on, is > a reinvention of DRMAA using technologies such as HTTP, REST, JSON, > Protobuf. It's a pretty simple API and message type

Re: [go-nuts] nil maps

2017-10-17 Thread Christian Himpel
The spec defines: "A nil map is equivalent to an empty map except that no elements may be added." https://golang.org/ref/spec#Map_types You could return a nil map, if you have no elements to add, and a caller would just need to read. On Tue, Oct 17, 2017 at 7:02 AM Dan Kortschak