Re: [go-nuts] labeled loop vs for statement inlining

2016-08-29 Thread Dave Cheney
Inlining is conservative. As well as the size of the code being inlined, current 40 units (unit has not scale), some operations are not inlined, as they are considered hairy. switch used to be considered hairy, 1.7 fixed that, for is still hairy. On Tuesday, 30 August 2016 15:58:30 UTC+10, Soko

Re: [go-nuts] labeled loop vs for statement inlining

2016-08-29 Thread Sokolov Yura
But still question is interesting: why decision is based on source code and not on instructions size? Both functions likely to produce same assembler code. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop r

Re: [go-nuts] reading with scanner.Bytes()

2016-08-29 Thread Tamás Gulácsi
If you can, you should reuse those slices, e.g. with sync.Pool. -- 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

Re: [go-nuts] reading with scanner.Bytes()

2016-08-29 Thread 'Chris Lu' via golang-nuts
Nice. Thanks! b0 := scanner.Bytes() b1 := make([]byte, len(b0)) copy(b1, b0) outChannel <- b1 Chris On Mon, Aug 29, 2016 at 8:41 PM, Caleb Spare wrote: > You can do > > b0 := scanner.Bytes() > b1 := make([]byte, len(b0)) > copy(b0, b1) > outC

Re: [go-nuts] reading with scanner.Bytes()

2016-08-29 Thread Caleb Spare
You can do b0 := scanner.Bytes() b1 := make([]byte, len(b0)) copy(b0, b1) outChannel <- b0 On Mon, Aug 29, 2016 at 8:23 PM, chris.lu via golang-nuts wrote: > I am reading a file line by line, and send it to a chan []byte, and consume > it on another goroutine. > > However, I found I must create

[go-nuts] reading with scanner.Bytes()

2016-08-29 Thread chris.lu via golang-nuts
I am reading a file line by line, and send it to a chan []byte, and consume it on another goroutine. However, I found I must create a new []byte, because the scanner.Bytes() returned a []byte slice that's shared, and the scanner may still write to the []byte slice. How to efficiently create a

[go-nuts] Re: certificates at /etc/ssl/certs/ getting ignored on FreeBSD

2016-08-29 Thread Dave Cheney
These are the locations that are searched on *BSD machines // Possible certificate files; stop after finding one. var certFiles = []string{ "/usr/local/share/certs/ca-root-nss.crt", // FreeBSD/DragonFly "/etc/ssl/cert.pem", // OpenBSD "/etc/openssl/

[go-nuts] Re: In case you missed it: language benchmarks for Go 1.7, and language adoption

2016-08-29 Thread Asit Dhal
Hi, Go1.7 is faster in most benchmarks, but still slower than Java in some benchmarks(like Go 1.6). GO Garbage Collector needs time to become mature like JVM. K-nucleotide, binary tree, Regex-dna are bad for GO(lack of fast GC and good standard libraries). But, for me, Go is an awesome substi

Re: [go-nuts] In case you missed it: language benchmarks for Go 1.7, and language adoption

2016-08-29 Thread 'Eric Johnson' via golang-nuts
Well, sure. I read that too. I think it is still useful that my intuition that Go is gaining adoption aligns with what prominent metrics are reporting, even if it is because the reporting changed how they measured. Eric. On Mon, Aug 29, 2016 at 5:22 PM, Ian Lance Taylor wrote: > On Mon, Aug 29,

[go-nuts] Re: Performance Counters

2016-08-29 Thread Mark Richman
Thanks Diego! I will check it out. Looks like it's what I'm after. On Monday, August 29, 2016 at 2:07:34 PM UTC-4, Diego Medina wrote: > > > Hi, > > You may want to look at > > https://golang.org/pkg/expvar/ > > If your app is already running the built in server, you can > > import _ "expvar" > >

Re: [go-nuts] In case you missed it: language benchmarks for Go 1.7, and language adoption

2016-08-29 Thread Ian Lance Taylor
On Mon, Aug 29, 2016 at 4:51 PM, 'Eric Johnson' via golang-nuts wrote: > > And then, for language adoption, the TIOBE language index for August of > 2016: > http://www.tiobe.com/tiobe-index/ > > (Note that the above is updated every six months, and I've not been able to > find a link to previous v

Re: [go-nuts] Behavior of calling (Context).Err without calling (Context).Done

2016-08-29 Thread Ian Lance Taylor
On Mon, Aug 29, 2016 at 4:21 PM, Stephen Day wrote: > Recently, we were examining some ill-structured code that called > (Context).Err() without first calling (Context).Done(). Typically, this > seems to return a nil error without any guarantees as to what that means, > but this doesn't seem to be

[go-nuts] certificates at /etc/ssl/certs/ getting ignored on FreeBSD

2016-08-29 Thread Niloy Debnath
What version of Go are you using (go version)? go version devel +e6f9f39 Mon Aug 29 18:25:33 2016 + linux/amd64 Checkout 1.7 from git master branch and compiled. What operating system and processor architecture are you using (go env)? GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOS

[go-nuts] certificates at /etc/ssl/certs/ getting ignored on FreeBSD

2016-08-29 Thread niloy . debnath
What version of Go are you using (go version)? go version devel +e6f9f39 Mon Aug 29 18:25:33 2016 + linux/amd64 Checkout 1.7 from git master branch and compiled. What operating system and processor architecture are you using (go env)? GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHO

[go-nuts] In case you missed it: language benchmarks for Go 1.7, and language adoption

2016-08-29 Thread 'Eric Johnson' via golang-nuts
Not that I think these account for much, but sort of fun to point at: https://benchmarksgame.alioth.debian.org/u64q/go.html (Short summary - now with Go 1.7, Go is faster for most benchmarks.) And then, for language adoption, the TIOBE language index for August of 2016: http://www.tiobe.com/tiob

[go-nuts] Behavior of calling (Context).Err without calling (Context).Done

2016-08-29 Thread Stephen Day
Recently, we were examining some ill-structured code that called (Context).Err() without first calling (Context).Done(). Typically, this seems to return a nil error without any guarantees as to what that means, but this doesn't seem to be called out explicitly. Should it be required to call Don

Re: [go-nuts] Conditional compiling for android

2016-08-29 Thread andrey mirtchovski
you can do this for the pure linux stuff: // +build !android,linux -- 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

Re: [go-nuts] Why does context.CancelFunc exist?

2016-08-29 Thread Sam Whited
On Mon, Aug 29, 2016 at 2:04 PM, Nate Finch wrote: > So, just a note... the CancelFunc type doesn't prevent you from passing in > any old func(), since those are considered effectively literals (IIRC), so > they can be automatically converted to the CancelFunc type. For example: > https://play.go

Re: [go-nuts] Why does context.CancelFunc exist?

2016-08-29 Thread Nate Finch
So, just a note... the CancelFunc type doesn't prevent you from passing in any old func(), since those are considered effectively literals (IIRC), so they can be automatically converted to the CancelFunc type. For example: https://play.golang.org/p/QNbVXorlEQ The only time the compiler will st

[go-nuts] Conditional compiling for android

2016-08-29 Thread sapna . todwal
As per the documentation in https://golang.org/pkg/go/build/ : Using GOOS=android matches build tags and files as for GOOS=linux in addition to android tags and files. So what if I want to compile a file on android but not for linux, because I have multiple targets , one of them being linux a

[go-nuts] Re: Performance Counters

2016-08-29 Thread Diego Medina
Hi, You may want to look at https://golang.org/pkg/expvar/ If your app is already running the built in server, you can import _ "expvar" and then you will see a lot of internal counters at localhost:6060/debug/vars you can then add your own counters to it, which will also be displayed und

[go-nuts] Re: Why can't you take the address of a function's return value?

2016-08-29 Thread adonovan via golang-nuts
On Monday, 29 August 2016 13:36:00 UTC-4, Conrad Irwin wrote: > > because of the automatic escape detection, I no longer think of a pointer > as being the intrinsic address of a value; rather in my mind the & operator > creates a new pointer value that when dereferenced returns the value. > >

[go-nuts] Re: Why can't you take the address of a function's return value?

2016-08-29 Thread Conrad Irwin
On Mon, Aug 29, 2016 at 10:17 AM, wrote:On Friday, 26 August 2016 23:58:53 UTC-4, T L wrote:And there is also an exception for the counter rule: map elements are not addressable.Just because you can use the assignment syntax m[k]=v to update a map element does not mean a map e

[go-nuts] Re: Why can't you take the address of a function's return value?

2016-08-29 Thread adonovan via golang-nuts
On Friday, 26 August 2016 23:58:53 UTC-4, T L wrote: > > And there is also an exception for the counter rule: map elements are not > addressable. > Just because you can use the assignment syntax m[k]=v to update a map element does not mean a map element is a variable ("addressable"). This is n

Re: [go-nuts] runtime: split stack overflow

2016-08-29 Thread Ian Lance Taylor
On Mon, Aug 29, 2016 at 8:19 AM, wrote: >> I'm only talking about changing Darwin. > > > Sorry, I meant pushing the gcc callee-saved registers in the assembly > sigtramp functions (for example in sys_darwin_amd64.s) as it is done in > crosscall2. I ran into the issue, that the content in the rbx

Re: [go-nuts] labeled loop vs for statement inlining

2016-08-29 Thread Ariel Mashraki
I didn't know it has more levels. thanks On Monday, August 29, 2016 at 6:09:19 PM UTC+3, Sam Whited wrote: > > On Mon, Aug 29, 2016 at 9:40 AM, Ariel Mashraki > > wrote: > > Can someone please explain why doesn't the f2 function get inlined ? > > If you build with m=2 (go build -gcflags -m=2)

Re: [go-nuts] runtime: split stack overflow

2016-08-29 Thread martin . strenge
> > I'm only talking about changing Darwin. > Sorry, I meant pushing the gcc callee-saved registers in the assembly sigtramp functions (for example in sys_darwin_amd64.s) as it is done in crosscall2. I ran into the issue, that the content in the rbx register was overwritten by the sigfwdgo()

Re: [go-nuts] labeled loop vs for statement inlining

2016-08-29 Thread Sam Whited
On Mon, Aug 29, 2016 at 9:40 AM, Ariel Mashraki wrote: > Can someone please explain why doesn't the f2 function get inlined ? If you build with m=2 (go build -gcflags -m=2) it will spit out a reason: > cannot inline f2: unhandled op for (closures with "for" in them apparently can't be inlined)

[go-nuts] [ANN] AstraNet for managing highly concurrent independent network streams

2016-08-29 Thread Maxim Kupriianov
Hi everyone, today I'd like to announce (and advertise a little bit) two packages for Go that we've developed in our company and use them in the core of our pure-Go backendstack. First one, AstraNet, is a multi-purpose Go component that is a stream multiplexer on the first place, and besides tha

Re: [go-nuts] labeled loop vs for statement inlining

2016-08-29 Thread Peter Mogensen
On 2016-08-29 16:59, 'Chris Manghane' via golang-nuts wrote: I can't explain exactly because my explanation is likely very flawed, but the logic you are looking for is in https://github.com/golang/go/blob/320ddcf8344beb1c322f3a7f0a251eea5e442a10/src/cmd/compile/internal/gc/inl.go#L186. Basical

Re: [go-nuts] labeled loop vs for statement inlining

2016-08-29 Thread 'Chris Manghane' via golang-nuts
I can't explain exactly because my explanation is likely very flawed, but the logic you are looking for is in https://github.com/golang/go/blob/320ddcf8344beb1c322f3a7f0a251eea5e442a10/src/cmd/compile/internal/gc/inl.go#L186. Basically, labeled loops are not considered "hairy" by the compiler and c

[go-nuts] labeled loop vs for statement inlining

2016-08-29 Thread Ariel Mashraki
Hello, Running `go build -gcflags -m` on the given code below will produce: main.go:3: can inline f1 main.go:24: inlining call to f1 Can someone please explain why doesn't the f2 function get inlined ? Thanks package main func f1() int { i := 0 loop: if i > 10 {

Re: [go-nuts] runtime: split stack overflow

2016-08-29 Thread Ian Lance Taylor
On Mon, Aug 29, 2016 at 12:18 AM, wrote: >> OK, then perhaps we need setsig in os_darwin.go to set >> the sigaction field to a new function, written in assembler, like >> sigtramp, but taking just the sigaction arguments. > > > Could you please explain, why it is necessary to use sa_tramp with a

[go-nuts] gomobile init should have a flag if we want only IOS or Android

2016-08-29 Thread Abhishek Sinha
While doing gomobile init on OSX, I get the following error gomobile: xcrun --show-sdk-path: exit status 1 xcrun: error: SDK "iphoneos" cannot be located xcrun: error: SDK "iphoneos" cannot be located xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos' Seems like xcode needs to be install

[go-nuts] Re: Go package management committee

2016-08-29 Thread Joe Blue
this looks great. in my dealing with different developers from non golang community, the package management has been a concern for them. for me, its no too bad once you find on the many, which can be mighty confusing for the new comer to golang. So, i really hope this committee ends up with th

Re: [go-nuts] Re: ANNOUNCE: renderview

2016-08-29 Thread Joe Blue
Hey everyone, That's great news. So trying this out i got stopped... seems i need gtk on OSX. i got lots trying to find out how to cleanly get gtk working on OSX. Their docs did not make sense to me. http://www.gtk.org/download/macos.php raised an issue. https://github.com/TheGrum/renderview/iss

Re: [go-nuts] runtime: split stack overflow

2016-08-29 Thread martin . strenge
> > OK, then perhaps we need setsig in os_darwin.go to set > the sigaction field to a new function, written in assembler, like > sigtramp, but taking just the sigaction arguments. Could you please explain, why it is necessary to use sa_tramp with a custom function instead of using the defau