`y` escape because the println use interface{} as its parameter, golang
can't know in compiling time what this parameter could be use (to be copy
to global or send to other goroutine). so it is the interface self make
golang hard to keep variable in stack
On Wednesday, June 2, 2021 at 1:30:49 A
I think the question is about `go:embed` directive in `_test.go` files will
be included in builds of non-test packages, right?
Don't know for sure, but I think:
- a) if you have `mypkg_test.go` and in it `package mypkg_test` then
`go:embed` will not get to your non test build as the package is d
On Tuesday, June 1, 2021 at 9:17:11 AM UTC-4 manlio@gmail.com wrote:
> When a file is embedded in a test file, will the file be embedded only in
> the test binary?
> The documentation says nothing about this case, but the data from go list
> seems to confirm that the file is only embedded in
On Tue, Jun 1, 2021 at 11:51 AM Torsten Bronger
wrote:
>
> Actually I am more interested in developments on the error handling
> front. I wonder whether
> https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md
> has been cast into code already.
It has not. The
Hallöchen!
Ian Lance Taylor writes:
> On Tue, Jun 1, 2021 at 9:39 AM Torsten Bronger
> wrote:
>
>> Is there already a possibility to give a WIP Go 2 compiler a
>> test? What is the best way to get informed for that? (This
>> group, the blog, …)
>
> There are no plans for anything called Go 2.
Whenever you take the address of something the compiler is going to have a hard
time with escape analysis due to aliasing. Especially with a complex function
like println with varadic args.
> On Jun 1, 2021, at 11:55 AM, 'Axel Wagner' via golang-nuts
> wrote:
>
>
> "escape" as in "the comp
There is also https://go2goplay.golang.org/ (which is perhaps misleadingly
named, given that there are no plans for Go 2)
On Tuesday, 1 June 2021 at 17:54:05 UTC+1 Ian Lance Taylor wrote:
> On Tue, Jun 1, 2021 at 9:39 AM Torsten Bronger
> wrote:
> >
> > Is there already a possibility to give a
On Tue, Jun 1, 2021 at 6:39 PM Scott Beeker wrote:
> How are golang web applications on a scale of 1 to 10 for seo rankings?
>
> This scale is on a different dimension than that of the choice of Go!
Go doesn't impose any restrictions on your efforts of playing nice with a
search engine. But it r
"escape" as in "the compiler's escape analysis decides to put it on the
heap, instead of the stack". You can compile using `-gcflags=-m` to test
that yourself.
On Tue, Jun 1, 2021 at 6:39 PM Robert Glonek wrote:
> What do you mean by escape? It prints the ptr to y, like the previous
> prints the
On Tue, Jun 1, 2021 at 9:39 AM Torsten Bronger
wrote:
>
> Is there already a possibility to give a WIP Go 2 compiler a test?
> What is the best way to get informed for that? (This group, the
> blog, …)
There are no plans for anything called Go 2.
Perhaps you mean Go with generics support? That
How are golang web applications on a scale of 1 to 10 for seo rankings?
--
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.
What do you mean by escape? It prints the ptr to y, like the previous
prints the ptr to x. Y is the same pointer throughout, as it should be.
On Tuesday, 1 June 2021 at 14:51:50 UTC+1 tapi...@gmail.com wrote:
>
> package main
>
> func newIntPtr(n int) *int {
> return &n
> }
>
> func main() {
Hallöchen!
Is there already a possibility to give a WIP Go 2 compiler a test?
What is the best way to get informed for that? (This group, the
blog, …)
Tschö,
Torsten.
--
Torsten Bronger
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsu
I would strongly assume that the file is only embedded in the test binary.
In fact it is hard to imagine a design where it would not be that way.
If you really want to make sure, you could easily build two, identical
binaries, that differ only in that a very large file is embedded in the
test f
Here is a more definitive reply than my original reply.
I got as far as this
func BenchmarkPopCountSimple(b *testing.B) {
sum := 0 // Avoid dead code elimination.
for i := 0; i < b.N; i++ {
sum += PopCount(0x1234567890abcdef)
}
}
As you can see from the objdump, BenchmarkPop
"The closure then closes…". Weird typo.
On Tue, Jun 1, 2021 at 5:17 PM Axel Wagner
wrote:
> FWIW, I believe the crux here is that `y` itself escapes, not the pointee
> of `y`. The pointee escapes as well, but it's printed as `n moved to heap`.
> The close then closes over `y` (not over `*y`), me
FWIW, I believe the crux here is that `y` itself escapes, not the pointee
of `y`. The pointee escapes as well, but it's printed as `n moved to heap`.
The close then closes over `y` (not over `*y`), meaning it needs to store a
pointer to `y` as well. That is, I assume, why `y` escapes. However, I'm
On Tuesday, June 1, 2021 at 10:48:22 AM UTC-4 Jan Mercl wrote:
> On Tue, Jun 1, 2021 at 4:40 PM tapi...@gmail.com
> wrote:
>
> > The following is a tip to get an array pointer but avoid the array
> escaping.
>
> I don't think so. The pointer to the local array 't', stored in 'y'
> never le
Thanks for the explanations. I agree on them mostly.
But the println call doesn't make x escape, so I think println is not the
root cause making y escape.
In fact, I'm surprised that y doesn't escape without the last println call.
It looks gc is so smart that it translates "*y" to the value refere
On Tue, Jun 1, 2021 at 4:40 PM tapi...@gmail.com wrote:
> The following is a tip to get an array pointer but avoid the array escaping.
I don't think so. The pointer to the local array 't', stored in 'y'
never leaves the function, so there's no need for 't' to escape. See
the previous post.
>
>
The following is a tip to get an array pointer but avoid the array escaping.
package main
const N = 1<<13
var i = N-1
func main() {
var x = &[N]int{} // escapes to heap
println(x[i])
var t [N]int // not escape
var y = &t
println(y[i])
}
On Monday, May 24, 2021 at 4:25:18
On Tue, Jun 1, 2021 at 3:52 PM tapi...@gmail.com wrote:
By default, any local variable that has its address taken and that
address can outlive the function execution forces the variable to
escape, quite naturally as the stack frame with the variable is
destroyed upon returning from the function.
package main
func newIntPtr(n int) *int {
return &n
}
func main() {
x := newIntPtr(3)
y := newIntPtr(5)
c := make(chan bool)
go func() {
*y++
close(c)
}()
<-c
println(*x, *y)
println(&x)
//println(&y) // This line makes y escape.
}
--
You
When a file is embedded in a test file, will the file be embedded only in
the test binary?
The documentation says nothing about this case, but the data from go list
seems to confirm that the file is only embedded in the test binary.
Thanks
Manlio
--
You received this message because you are su
On Tuesday, June 1, 2021 at 12:29:27 AM UTC+2 Paul S. R. Chisholm wrote:
> This is not a serious problem, but it surprised me. (By the way, how can I
> post a message with code formatting?)
>
> I'd like to create table-driven benchmarks:
> https://blog.golang.org/subtests.
>
> To that end, I
On Tue, Jun 1, 2021 at 12:29 AM Paul S. R. Chisholm
wrote:
> P.S.: Out of curiosity, how can I post a message with fancy code examples
> like this one?
> https://groups.google.com/g/golang-nuts/c/5DgtH2Alt_I/m/hlsqdRSGAgAJ
FTR, that's not fancy in my books. Code is best posted to email list
26 matches
Mail list logo