Re: [go-nuts] Randomizing contents of a file

2016-09-20 Thread Bakul Shah
Not quite what you asked for but rather than use N goroutines, why not slurp in the whole file in a list ([]string) of lines and then output them in random order? Something like for _, i := range deal(len(lines)) { fmt.Println(lines[i]) } Where you'd write deal(n) to return a list of n

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread Ian Davis
On Tue, Sep 20, 2016, at 04:15 PM, Gabriel Adumitrachioaiei wrote: > You might be right, but I just don't realize how. Since capacity will > be 2x or 1.5x as before, reallocating the slice will not happen often. > Or do you think that this would still be worse than copying almost all > slice

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread 'Axel Wagner' via golang-nuts
if we assume, that the number of elements N is roughly stable (so pops and pushes are roughly balanced): • If we append and reslice, we need to reallocate every N pops, because when space runs out, append will allocate 2N elements, so it has space for N new ones. After N pop/push sequences, it

[go-nuts] Re: http ssl "can't identify protocol"

2016-09-20 Thread Greg Saylor
Yeah I'm trying to figure out how to get a concise example of this - my deepest apologies. I did try it with default ListenAndServeTLS and it exhibited the same problem. There is no Hijack calls, x/net/ipv4. This is really pretty bare-bones http service. I'd say its about 100 reqs/sec on

[go-nuts] Govendor and Docker Build Container issues

2016-09-20 Thread sc28
I have a application structure as follows in my GoPath: --/ myproject | |-- apps |-- app1 |-- main.go |-- app2 |-- main.go |-- appN |-- main.go |-- libs

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread Gabriel Adumitrachioaiei
You might be right, but I just don't realize how. Since capacity will be 2x or 1.5x as before, reallocating the slice will not happen often. Or do you think that this would still be worse than copying almost all slice everytime there is a pop ? On Tuesday, September 20, 2016 at 5:59:27 PM

Re: [go-nuts] [ANN] go-scp: a scp client library in go

2016-09-20 Thread 'Paul Borman' via golang-nuts
I would suggest just putting your package out there and see how it is received. At some point, if it becomes the defacto package, moving it might make sense. I actually wrote an internal SCP package that works with a ssh multiplexer built on top of crypto/ssh. For various reasons, I am not in a

Re: [go-nuts] pprof: what are runtime.scanobject/gentraceback/pcvalue/etc

2016-09-20 Thread Ian Lance Taylor
On Tue, Sep 20, 2016 at 8:17 AM, mhhcbon wrote: > > on my way to learn to use pprof, i now face some intriguing results with > lots of runtime.* calls, > > can you help me to understand what those call are and how i should care > about ? > > (pprof) top30 > 8720ms of

[go-nuts] [ANN] Cgogen - automatic Go bindings generator released

2016-09-20 Thread Maxim Kupriianov
Hello everyone, today I'm glad to announce that after 3 months of full-time development back in 2015 and after 1 year of part-time field testing and improvements in 2016, an automatic CGo bindings generator for Golang is finally released to the public. Visit https://cgogen.com Sources:

[go-nuts] Re: [ANN] Cgogen - automatic Go bindings generator released

2016-09-20 Thread Markus Zimmermann
This looks pretty neat. We did something similar for https://github.com/go-clang/ The generator is here https://github.com/go-clang/gen and a resulting binding is here https://github.com/go-clang/v3.7 Maybe we can find some inspiration from each others projects? It would be also interesting to

[go-nuts] Randomizing contents of a file

2016-09-20 Thread Unknown User
Hi All, I am trying to print the contents of a file randomizing the lines. The following code works, but does not exit even after all the lines are read. What needs to be done to correct it? package main import( "fmt" "bufio" "os" "math/rand" "time" ) func main() {

[go-nuts] Randomizing contents of a file

2016-09-20 Thread Dave Cheney
Break breaks out of the select, not the for. Return would work here, or you could use a labled break. -- 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] Randomizing contents of a file

2016-09-20 Thread Marvin Renich
* Unknown User [160920 06:43]: > Hi All, > > I am trying to print the contents of a file randomizing the lines. > The following code works, but does not exit even after all the lines are > read. > What needs to be done to correct it? Try this

Re: [go-nuts] Re: [ANN] Cgogen - automatic Go bindings generator released

2016-09-20 Thread Maxim Kupriianov
Hi Markus, nice project! I must agree that the subject-specific bindings will always be superior over the generic ones. Another good example of that is https://github.com/therecipe/qt bindings with custom generator as well. As for LLVM, I'm trying to avoid using it for now, because that's a very

[go-nuts] http ssl "can't identify protocol"

2016-09-20 Thread Greg Saylor
Hello, I've been struggling with someone all day on a very busy server. And I'm at a loss as to what is going on. I have a Go server listening on two ports, like so: tls_config := MustGetTlsConfiguration(*ssl_cert, *ssl_key, *ssl_ca) listener, _ :=

[go-nuts] Crypto/rsa : OAEP documentation can lead to misunderstanding regarding max message length, is it a bug?

2016-09-20 Thread AnomalRoil
Hi there, I was reading the Crypto/RSA documentation, since I'm using OAEP encryption for testing purposes. So I read this which ends with: > The message must be no longer than the length of the public modulus less twice the hash length *plus

[go-nuts] Sorting slice of structs

2016-09-20 Thread Arie van Wingerden
Hi, Still a beginner ... first take at a bit more difficult thing. I cannot get this https://play.golang.org/p/qgBLH0r_vq to work. Compiler says: cannot use courses (type []Course) as type sort.Interface in argument to sort.Sort: []Course does not implement sort.Interface (missing Len

Re: [go-nuts] Sorting slice of structs

2016-09-20 Thread Jan Mercl
Types []Course and Courses are distinct types. courses have type []Courses because that's what the parameter to make is. Change it to Courses, ie. courses := make(Courses, maxrow) On Tue, Sep 20, 2016, 19:44 Arie van Wingerden wrote: > Hi, > > Still a beginner ... first take

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread Ian Davis
On Tue, Sep 20, 2016, at 03:54 PM, Gabriel Adumitrachioaiei wrote: > Well, the capacity will be reduced by one. I don't think this makes > much difference. It makes a difference for a long running service that repeatedly pushes and pops. Ian -- You received this message because you are

[go-nuts] pprof: what are runtime.scanobject/gentraceback/pcvalue/etc

2016-09-20 Thread mhhcbon
Hi, on my way to learn to use pprof, i now face some intriguing results with lots of runtime.* calls, can you help me to understand what those call are and how i should care about ? (pprof) top30 8720ms of 14380ms total (60.64%) Dropped 118 nodes (cum <= 71.90ms) Showing top 30 nodes out of

Re: [go-nuts] Wordbreak and word extraction in Go?

2016-09-20 Thread 'Ingo Oeser' via golang-nuts
Thanks for the suggestion, but I am looking for an implementation of http://unicode.org/reports/tr29/ -- 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] Pop out first element of a slice.

2016-09-20 Thread 'Axel Wagner' via golang-nuts
FWIW, I whipped up a short benchmark for this and it seems to confirm my intuition. For small N (depending on the exact setup, on my machine, the threshold was around N ~ 16 to 20) the copy approach is significantly faster, but for growing N the quadratic behavior of the copy quickly makes it much

Re: [go-nuts] [ANN] go-scp: a scp client library in go

2016-09-20 Thread Hiroaki Nakamura
2016-09-21 0:59 GMT+09:00 Paul Borman : > I would suggest just putting your package out there and see how it is > received. At some point, if it becomes the defacto package, moving it might > make sense. OK, I understood. > > I actually wrote an internal SCP package that

Re: [go-nuts] Calling a Go function from asm ("fatal error: missing stackmap")

2016-09-20 Thread Caleb Spare
Thanks very much for your reply, Ian. I had hoped this would not be the answer, though :) I think I can arrange to avoid calling from asm to Go at a minor cost. That sounds like the best solution here. Creating the stack map manually might be interesting exercise for learning about this corner

Re: [go-nuts] Wordbreak and word extraction in Go?

2016-09-20 Thread Shawn Milochik
How about strings.Fields? https://golang.org/pkg/strings/#Fields -- 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. For

[go-nuts] Wordbreak and word extraction in Go?

2016-09-20 Thread 'Ingo Oeser' via golang-nuts
Hi all, I am pretty sure I am overlooking something in the repository https://godoc.org/golang.org/x/text but I cannot find something to split text into words according to the next Unicode word splitting algorithm. Has anyone examples or can point me to the right direction? Can anyone confirm

[go-nuts] Re: Govendor and Docker Build Container issues

2016-09-20 Thread Daniel Theophanes
I would run govendor list Does it report any external packages? If so run "govendor add +external" On Tuesday, September 20, 2016 at 8:12:16 AM UTC-7, sc28 wrote: > > I have a application structure as follows in my GoPath: > > --/ myproject > | > |-- apps >|-- app1

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread Gabriel Adumitrachioaiei
Very good mathematical explanation. Thanks! On Tuesday, September 20, 2016 at 7:24:39 PM UTC+3, Axel Wagner wrote: > > if we assume, that the number of elements N is roughly stable (so pops and > pushes are roughly balanced): > > • If we append and reslice, we need to reallocate every N pops,

[go-nuts] Re: create a .rpm file for go app.

2016-09-20 Thread mhhcbon
hi, if that can help you i did this package, https://github.com/mh-cbon/go-bin-rpm i m not pro packager, but that did work for me. hope this help. Le mardi 20 septembre 2016 20:53:39 UTC+2, sujith...@gmail.com a écrit : > > > Right now, to build my .rpm package, I'm using this website: >

[go-nuts] Govendor and Docker Build Container issues

2016-09-20 Thread Tamás Gulácsi
Is your local files accessible to your devops? Maybe set "-e GOPATH=/go/app:/local -v $GOPATH/src/lib:/local/src/lib:ro" or something? Provide the host (local) GOPATH to the container, accessible under the container's GOPATH. -- You received this message because you are subscribed to the

Re: [go-nuts] Sorting slice of structs

2016-09-20 Thread xingtao zhao
Or: sort.Sort(Courses(course)) On Tuesday, September 20, 2016 at 10:50:15 AM UTC-7, Jan Mercl wrote: > > Types []Course and Courses are distinct types. courses have type []Courses > because that's what the parameter to make is. Change it to Courses, ie. > > courses := make(Courses, maxrow) > >

Re: [go-nuts] [ANN] go-scp: a scp client library in go

2016-09-20 Thread 'Paul Borman' via golang-nuts
For cancellation you run the actual operation in a goroutine and return results on a channel. You can then select on the Deadline from the context and the returned result. If the deadline hits, you just shut down the SSH session. Does that make sense? -Paul On Tue, Sep 20, 2016 at 3:36

Re: [go-nuts] net/http: In the infinite loop, refused all requests.

2016-09-20 Thread Justin Israel
I'm not an expert, but this looks to be the expected behaviour to me. If you have GOMAXPROCS=8 and you tie up 8 goroutines with infinite loops, then there is nothing left to service requests. They are spinning the cpus without any kind of context switching points. This kind of behaviour has been

Re: [go-nuts] net/http: In the infinite loop, refused all requests.

2016-09-20 Thread Justin Israel
http://dave.cheney.net/2015/08/08/performance-without-the-event-loop Goroutines Rather than relying on the kernel to manage their time sharing, goroutines are cooperatively scheduled. The switch between goroutines only happens at well defined points, when an explicit call is made to the Go

[go-nuts] Re: create a .rpm file for go app.

2016-09-20 Thread Rajanikanth Jammalamadaka
Build your binary and then use fpm? https://github.com/jordansissel/fpm On Tuesday, September 20, 2016 at 2:53:39 PM UTC-4, sujith...@gmail.com wrote: > > > Right now, to build my .rpm package, I'm using this website: > https://packager.io/ > > However, I would like to automate this in our prod

[go-nuts] Re: memory profiler for benchmark test reports 0s across the board

2016-09-20 Thread 'Ethan Kennedy' via golang-nuts
Dave, Thank you for the tip. That does at least show me some measurements of allocations. I guess I was hoping to do some more fine-grained analysis, if only as an educational exercise. So, I tried using the runtime/pprof package to write a heap profile at a specific point in my program and

Re: [go-nuts] Ivy crashes on iOS 10

2016-09-20 Thread David Crawshaw
I'm going to look into pushing a new version with 1.7. On Mon, Sep 19, 2016 at 10:39 AM, Jan Mercl <0xj...@gmail.com> wrote: > On Mon, Sep 19, 2016 at 3:58 PM wrote: > >> Anybody with same experiences? > > https://github.com/robpike/ivy/issues/29 > > -- > > -j > > -- >

Re: [go-nuts] [ANN] go-scp: a scp client library in go

2016-09-20 Thread Hiroaki Nakamura
Hi Paul, Thanks for your feedback! 2016-09-20 0:02 GMT+09:00 Paul Borman : > Adding an scp package is a nice addition. I agree. Should I send a pull request to https://github.com/golang/crypto? If yes, what package? golang.org/x/crypto/scp or golang.org/x/crypto/ssh/scp? >

[go-nuts] playground URL to fetch code only

2016-09-20 Thread Marvin Renich
Is there a way to take a playground URL, such as https://play.golang.org/p/Vg6f0gSs3l, and modify it (e.g. with a query string) so that you can retrieve just the code as text without the surrounding html? Something like curl 'https://play.golang.org/p/Vg6f0gSs3l?text' If not, would such a

[go-nuts] Re: Camel Enterprise Integration Patterns in golang

2016-09-20 Thread adrian . lopez . gomez
Hi Antonio, It seems the project was deleted. Did you continue it elsewhere? Regards, Adrian. On Friday, 6 February 2015 12:29:10 UTC+1, Antonio Linari wrote: > > Hi, > here you can find a 1st version, very basic, of Gamel (Camel Enterprise > Integration Patterns in Golang) > >

[go-nuts] Re: memory profiler for benchmark test reports 0s across the board

2016-09-20 Thread Dave Cheney
Can you share a small runable reproduction which shows the problem ? On Tuesday, 20 September 2016 23:26:29 UTC+10, Ethan Kennedy wrote: > > Dave, > > Thank you for the tip. That does at least show me some measurements of > allocations. I guess I was hoping to do some more fine-grained analysis,

[go-nuts] Re: http ssl "can't identify protocol"

2016-09-20 Thread James Bardin
It would really help if we had some complete code to reproduce the issue. It sounds like the server isn't closing connections, but with only these simple handlers I don't see where that could happen. Are there any Hijack calls, x/net/ipv4, or network related syscalls anywhere in your code?

Re: [go-nuts] Re: playground URL to fetch code only

2016-09-20 Thread Marvin Renich
* Ivan Anfilatov [160920 10:36]: > https://play.golang.org/p/Vg6f0gSs3l.go > > compile - post request to https://play.golang.org/compile in body request - > source > response - json Thanks, Ivan! ...Marvin -- You received this message because you are subscribed to

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread Gabriel Adumitrachioaiei
Well, the capacity will be reduced by one. I don't think this makes much difference. On Tuesday, September 20, 2016 at 5:44:20 PM UTC+3, Ian Davis wrote: > > On Tue, Sep 20, 2016, at 03:23 PM, Gabriel Adumitrachioaiei wrote: > > I don't understand something when I want to pop out first element

[go-nuts] Re: playground URL to fetch code only

2016-09-20 Thread Ivan Anfilatov
https://play.golang.org/p/Vg6f0gSs3l.go compile - post request to https://play.golang.org/compile in body request - source response - json вторник, 20 сентября 2016 г., 16:09:47 UTC+3 пользователь Marvin Renich написал: > > Is there a way to take a playground URL, such as >

[go-nuts] Ivy crashes on iOS 10

2016-09-20 Thread avulagaurav
Yeah me too -- 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. For more options, visit

[go-nuts] Pop out first element of a slice.

2016-09-20 Thread Gabriel Adumitrachioaiei
I don't understand something when I want to pop out first element of a slice and use it. Here is my version: s := []int{1,2,3} first := s[0] s = s[1:] Here is a version that I saw in the standard library: https://golang.org/src/database/sql/sql.go#L791 first := s[0] copy(s, s[1:]) s = s[:len(s)

Re: [go-nuts] playground URL to fetch code only

2016-09-20 Thread Marvin Renich
* Nicolas Martyanoff [160920 10:07]: > curl 'https://play.golang.org/p/Vg6f0gSs3l.go', i.e. just appending '.go' will > do the trick. Excellent! Thank you! ...Marvin -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To