Re: [go-nuts] Re: [Newbie] Why this code is so slow?

2017-02-26 Thread Michael Jones
Functionally similar...i use a time/memory tradeoff that makes factoring much faster but uses more memory. Other than that, very similar. On Sun, Feb 26, 2017 at 10:34 PM, Michael Jones wrote: > Maybe so. I'll look. The gain inside my v1 and v2 versions comes from > avoidable allocations that I

[go-nuts] Regarding os.Stdout

2017-02-26 Thread Curtis Paul
I have the following code. How might I parse the os.Stdout data into a map? Basically I want to read audio interfaces and put them in some sort of data structure. package main import ( "github.com/gordonklaus/portaudio" "os" "text/template" ) var tmpl = template.Must(template.New("").Parse( `

Re: [go-nuts] Is uint(v) when v is minus because a huge number supposed behavior?

2017-02-26 Thread Felix Sun
Thank you for the clarification. Axel Wagner 于2017年2月27日 周一上午8:43写道: > Because v := -1 declares a new variable and saves it in v - and the > default type of an integer constant is int. After that, this int gets > converted to a uint, which is fine. > In the case of uint(-1), you have an untyped co

Re: [go-nuts] Is uint(v) when v is minus because a huge number supposed behavior?

2017-02-26 Thread 'Axel Wagner' via golang-nuts
Because v := -1 declares a new variable and saves it in v - and the default type of an integer constant is int. After that, this int gets converted to a uint, which is fine. In the case of uint(-1), you have an untyped constant, which you then try to cast directly to a specific type (making a typed

[go-nuts] Re: Goroutine in a for loop: Closure versus direct

2017-02-26 Thread 'simon place' via golang-nuts
IFAIK they are the same, and could be compiled to the same thing. it seems to me a closure with its whole context just passed on, isn't doing anything. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop rece

Re: [go-nuts] Goroutine in a for loop: Closure versus direct

2017-02-26 Thread Dan Kortschak
On Sat, 2017-02-25 at 09:03 +, Jan Mercl wrote: > They're not, #2 has a data race. There is no race, the go routine is not a closure. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails f

Re: [go-nuts] Is uint(v) when v is minus because a huge number supposed behavior?

2017-02-26 Thread Felix Sun
But why these two way don't have consistent behavior ? uint(-1) v :=-1 uint(v) Michael Jones 于2017年2月26日 周日上午11:35写道: > yes. > https://en.wikipedia.org/wiki/Two's_complement > > On Sat, Feb 25, 2017 at 10:21 PM, Felix Sun wrote: > > https://play.golang.org/p/TmxMmltHGH > > package main > > i

[go-nuts] [golang.org/x/oauth2] scopes in AuthCodeURL call?

2017-02-26 Thread antihax
I have a use case where scopes change per token (the user is able to pick scopes before starting the oauth2 interaction). Would it be possible to add `scopes []string` to AuthCodeURL so they can be changed per request? Currently I am changing `oauthConfig.Scopes` per call, wrapped with a mutex

[go-nuts] Casting []byte to []uint64

2017-02-26 Thread Bill Katz
Hi, We'd like to do a zero-copy conversion of []byte to []uint64 where the underlying memory for the byte slice is properly aligned for N uint64 values. After looking at (6) in the unsafe package documentation , I'm wondering if the code below is valid

Re: [go-nuts] Why does my program hang?

2017-02-26 Thread Martin Schnabel
big.NewInt(int64(unsafe.Sizeof(char also this line will will define the maximum of the random number which is 4. so all the random runes are 0 <= r <= 4 which are all not graphic. is this more what you expect https://play.golang.org/p/61hzuNj1nF it uses append instead of the decrementing

Re: [go-nuts] Why does my program hang?

2017-02-26 Thread Martin Schnabel
> i-- by decrementing i in the case of i > 0 and a non graphic rune you run the loop possibly indefinitely -- 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 gola

[go-nuts] Re: HTML template behaviour changed in Go 1.8?

2017-02-26 Thread Jochen Voss
Hi Владимир, On Sunday, 26 February 2017 17:06:16 UTC, Владимир Мулько wrote: > > Hello, i had similar issue with empty block inserts in Go 1.8, > after changing {{block "name" .}}{{end}} to {{template "name"}} template > starts working. > It looks like this fixed the issue for me, too. Thanks!

[go-nuts] two new google groups for the UK Go community

2017-02-26 Thread Simon Ritchie
I've just created two Google groups for the UK Go community. The group golang-uk is for discussions about Go that are mainly of interest to people in the UK. Go is Go wherever you are, so I don't expect this group to carry many technical discussions, if any. I envisage that its main use will

[go-nuts] Re: HTML template behaviour changed in Go 1.8?

2017-02-26 Thread Jochen Voss
Since this is a change in behaviour since Go 1.7.5, I have now reported this as a bug: https://github.com/golang/go/issues/19294 -- 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, se

[go-nuts] Why does my program hang?

2017-02-26 Thread jamalsmith95 . bc
package main import ( "fmt" "os" "strconv" "crypto/rand" "math/big" "unicode" "unsafe" ) func main() { num, err := strconv.ParseUint(os.Args[1],10,64) if err != nil { panic(err) } randrunes := make([]rune,num,num) var char rune for i :=

Re: [go-nuts] Re: [Newbie] Why this code is so slow?

2017-02-26 Thread Michael Jones
Maybe so. I'll look. The gain inside my v1 and v2 versions comes from avoidable allocations that I did not worry about at first, but did in the second case. The parallel speed up is the beauty of Go and nothing to do with me or algorithm details. I will look at your program to see how similar our

[go-nuts] Re: Error type casting is something strange.

2017-02-26 Thread Andrei Tudor Călin
Hello. If any concrete value has been stored in an interface value - including a nil pointer of some type - the interface will not be nil. See this section in the FAQ for more details: https://golang.org/doc/faq#nil_error On Sunday, February 26, 2017 at 6:06:16 PM UTC+1, 장재휴 wrote: > > Hi. > >

Re: [go-nuts] Re: [Newbie] Why this code is so slow?

2017-02-26 Thread Éric Jacoboni
Le dimanche 26 février 2017 19:05:38 UTC+1, Michael Jones a écrit : > > Back on the ground for a bit with speedup news. My first ever performance > tuning over Iran turned out well, the 100 case formerly... > on the same MacBook Pro. I also changed the code to take advantage of the MBPs

Re: [go-nuts] Re: [Newbie] Why this code is so slow?

2017-02-26 Thread Michael Jones
Back on the ground for a bit with speedup news. My first ever performance tuning over Iran turned out well, the 100 case formerly... real 0m1.282s user 0m1.324s sys 0m0.027s ...is now down to real 0m0.868s user 0m0.858s sys 0m0.006s on the same MacBook Pro. I also changed the code to take a

[go-nuts] Re: HTML template behaviour changed in Go 1.8?

2017-02-26 Thread Владимир Мулько
Hello, i had similar issue with empty block inserts in Go 1.8, after changing {{block "name" .}}{{end}} to {{template "name"}} template starts working. may be it is affected by commit https://github.com/golang/go/commit/2b583a190eb14c69bffe5d488d2d6d3862fe76ea in file src/text/template/template

[go-nuts] Error type casting is something strange.

2017-02-26 Thread bbugguj
Hi. This is very simple program for testing about error type. I found that error type casting is something strange. I thing `err2` should be nil, but it is not nil. Someone can explain about this result? https://play.golang.org/p/icjhpCCNe_ -- package main import ( "fmt" ) type MyErro

Re: [go-nuts] Re: Is uint(v) when v is minus because a huge number supposed behavior?

2017-02-26 Thread Marvin Renich
* peterGo [170225 22:40]: > On Saturday, February 25, 2017 at 10:21:49 PM UTC-5, Felix Sun wrote: > > https://play.golang.org/p/TmxMmltHGH > > > > package main > > > > import ( > > "fmt" > > ) > > > > func main() { > > var f int = -1 > > fmt.Println("become huge number:", uint(f)) > > fmt.Println(

[go-nuts] HTML template behaviour changed in Go 1.8?

2017-02-26 Thread Jochen Voss
Hello, I am using Go templates to generated the files inside an EPUB container. Since I switched to Go version 1.8 the output of my rendered templates seems to be no longer deterministic and often bit which used to be always there are now missing. Minimal working (well, broken) example: http

Re: [go-nuts] Re: [Newbie] Why this code is so slow?

2017-02-26 Thread Jesper Louis Andersen
On Sun, Feb 26, 2017 at 12:45 PM Éric Jacoboni wrote: > > Are you sure? When i write age := 20, i don't play with memory index... > So, i have to write age := int32(20) or var age int32 = 20, which is > rather boring, imho. > > > > It is a trade-off in which you have a couple of options to choose

Re: [go-nuts] Go Language tests

2017-02-26 Thread brainman
Or you can run src\all.bat on Windows. Alex -- 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 htt

[go-nuts] Re: [Newbie] Why this code is so slow?

2017-02-26 Thread Éric Jacoboni
Le dimanche 26 février 2017 11:46:17 UTC+1, Tamás Gulácsi a écrit : > > > Int is for indexung memory. Are you sure? When i write age := 20, i don't play with memory index... So, i have to write age := int32(20) or var age int32 = 20, which is rather boring, imho. -- You received this mess

[go-nuts] 1.8, plugin: A solution load, check, deploy, consume ?

2017-02-26 Thread mhhcbon
Hi, Since 1.8 there is this great plugin module, I m really interested to take advantage of it. But several questions rises when I think of it, dumping them here and hope to get some feedback Not starting by the deployment, I first wonder about their storage and organization on the end user syst

[go-nuts] Re: first try with templates

2017-02-26 Thread Simon Ritchie
Sorry, that last response could have been a bit more helpful. My templates take a structure as input. When I execute the template, I pass the structure to the template. This line in the template: {{$resourceNameLower := .NameWithLowerFirst}} takes the contents of the NameWithLowerFirst

[go-nuts] Re: first try with templates

2017-02-26 Thread Simon Ritchie
The documentation for Go templates is ... scanty. My scaffolder https://github.com/goblimey/scaffolder includes several templates that set variables. It does other useful stuff such as driving template production from a JSON spec, creating templates from other templates, and so on. Regards S

[go-nuts] Re: [Newbie] Why this code is so slow?

2017-02-26 Thread Tamás Gulácsi
If you know you need int32, then do so, explicitly. Int is for indexung memory. -- 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...@googlegrou

[go-nuts] Re: [Newbie] Why this code is so slow?

2017-02-26 Thread Éric Jacoboni
Thanks for all your answers... After further investigations, i've got the same conclusion: the culprit is int64 and, more specifically, the mod operation. Java is faster because its ints are 32 bits. Changing all int with int32 in my code gives 3.2secs, which seems more reasonnable. So, is

Re: [go-nuts] Re: [Newbie] Why this code is so slow?

2017-02-26 Thread Michael Jones
I just coded up a quick amicable/perfect finder (using an expensive inner mechanism) and still it runs in 1.3 seconds in single processor mode. The times are not comparable because the techniques may not be the same, but I don't think it is fair to judge Go as slow. babar:amicable mtj$ time amicab