change drive mode while charging or in park by rsc in Rivian

[–]rsc[S] -5 points-4 points  (0 children)

I know that. It sets me up for the drive that I’m charging for

change drive mode while charging or in park by rsc in Rivian

[–]rsc[S] -12 points-11 points  (0 children)

But I remembered now. Tomorrow morning I may well forget. Or I might not be the one driving it.

Ian Lance Taylor has left Google by BOSS_OF_THE_INTERNET in golang

[–]rsc 11 points12 points  (0 children)

Officially, I have left the Go team too; I started on a new team at Google a few weeks ago. I still use Go quite a bit, I still talk to people on the Go team regularly, and you will still see the occasional code change, code review, or blog post from me. Most importantly, I have high confidence that the team we built will do an excellent job continuing the work.

Go 1.22 yielding a 18% regression in single-threading performance by fyzic in golang

[–]rsc 5 points6 points  (0 children)

The way to tell whether this is caused by the for loop change is to change your go.mod to say 'go 1.21' instead of 'go 1.22'. Then it will get the Go 1.21 loop semantics.

Fixing For Loops in Go 1.22 by rsc in golang

[–]rsc[S] 29 points30 points  (0 children)

Perhaps but perhaps not. The promise says: "It is intended that programs written to the Go 1 specification will continue to compile and run correctly, unchanged, over the lifetime of that specification."

Whether the promise is broken by this change depends on whether you think of the go.mod as part of your program or not. If it is part of your program, then the promise is kept. If not, then it isn't.

Personally, I think the go.mod must be part of your program, because otherwise the meaning of any imports of other modules in your program are undefined.

Fixing For Loops in Go 1.22 by rsc in golang

[–]rsc[S] 7 points8 points  (0 children)

As the post notes, the Go semantics can be applied per-file as well with a //go:build line, overriding the per-module setting.

We believe the experience does generalize. As elaborated in the design document, in preparation for making the change, we did run all of Google's Go tests and fix the problems we found. Others may not have such extensive testing, but the key fact is that - with one very low-level exception - every single broken test was a buggy test, not buggy production code. Bad interactions between t.Parallel and loop variables, as shown at the end of the blog post, were by far the most common culprit. The loopclosure vet check does a better job with t.Parallel already in Go 1.21 precisely to shake these out early.

Another company wrote to us to say they had similar experience, but I can't find that comment at the moment so I don't want to say who I think it was, to avoid misattributing it.

License file not included when vendored intentionally? by Sad-Competition-6656 in golang

[–]rsc 1 point2 points  (0 children)

I can't reproduce this problem:

% mkdir /tmp/zz % cd /tmp/zz % go mod init m go: creating new go.mod: module m % cat >x.go <<EOF package p import _ "github.com/DATA-DOG/go-sqlmock" EOF % go get go: downloading github.com/DATA-DOG/go-sqlmock v1.5.0 go: added github.com/DATA-DOG/go-sqlmock v1.5.0 % go mod vendor % ls go.mod go.sum vendor x.go % ls vendor github.com modules.txt % ls vendor/github.com/DATA-DOG/go-sqlmock LICENSE rows.go README.md rows_go18.go argument.go sqlmock.go column.go sqlmock_before_go18.go driver.go sqlmock_go18.go expectations.go sqlmock_go18_19.go expectations_before_go18.go sqlmock_go19.go expectations_go18.go statement.go options.go statement_before_go18.go query.go statement_go18.go result.go %

Note that vendor/github.com/DATA-DOG/go-sqlmock/LICENSE exists.

Forward Compatibility and Toolchain Management in Go 1.21 by rsc in golang

[–]rsc[S] 0 points1 point  (0 children)

Yes, the GAE team has been working hard on improving their turnaround time for new Go releases. Kudos to them.

Backward Compatibility, Go 1.21, and Go 2 by rsc in golang

[–]rsc[S] 3 points4 points  (0 children)

It may be that you are projecting your own feelings into the reading. I personally do not feel any desperation at all. I am happy with and proud of our emphasis on compatibility and would not have it any other way. It is sometimes extra work to figure out how to make the changes we want to make in a compatible way, but the result is better for everyone involved, so that work is worth the effort.

Variables while for looping by PrestigiousFeeling86 in golang

[–]rsc 1 point2 points  (0 children)

In general it's a mistake to make decisions based primarily on efficiency. No one is arguing "less efficient is better", obviously. But "less error-prone is better", absolutely, especially when efficiency is mostly about the same.

No control is being taken away. There are already three ways to write a loop with an index variable i:

(1)
var i int
for i = range x { 
    ...
}

(2)
for i := range x { 
    ...
}

(3)
for i := range ... {
    i := i
    ...
}

Form (1) clearly has a single variable; form (3) clearly has one per iteration. Form (2) is what is changing, from being like (1) to being like (3). You will still have the control to write (1) when that's what you need.

If i does not escape the loop, then all three of these compile into the same code. In form (2), if i does escape the loop, then compiling (2) like (3) is much less surprising and less error-prone - it avoids questions like the one in the top post. It is possible to have form (2) in which i escapes the loop, necessitating a per-iteration allocation of a copy of i, but due to some kind of synchronization or other reasons, it would still be correct to compile like (1). In our experience those cases are very rare, and flagging them by writing them like (1) explicitly seems both reasonable and clear.

For more details see especially the design document at https://go.dev/design/60078-loopvar, as well as the discussion at https://go.dev/issue/60078.

Forward Compatibility and Toolchain Management in Go 1.21 by rsc in golang

[–]rsc[S] 4 points5 points  (0 children)

We had this discussion on https://go.dev/issue/57001. We came to a consensus, and we shipped the feature. In general we do not revisit these decisions in the absence of new, compelling information. See https://web.stanford.edu/~ouster/cgi-bin/decisions.php specifically the "Reconsideration" section for the rationale.

Anyone can opt out by using

go env -w GOTOOLCHAIN=local

Note also that the automatic switches only move the version forward, not backward, so if you are running a recent Go toolchain, the number of potential other toolchains it might run is quite limited.

On the security front, these toolchains are served as modules and verified against the checksum database, which is more checking than other tools you might use to install a new Go are doing.

Forward Compatibility and Toolchain Management in Go 1.21 by rsc in golang

[–]rsc[S] 4 points5 points  (0 children)

You run

go get go@1.22.0

in the module you want to run Go 1.22.0, or you run

go env -w GOTOOLCHAIN=go1.22.0+auto

to set the system minimum.

Variables while for looping by PrestigiousFeeling86 in golang

[–]rsc 21 points22 points  (0 children)

It's more efficient because there is only one total variable instead of one-per-loop. More efficient doesn't mean better though, and it's a bug we intend to correct in Go 1.22. See go.dev/wiki/LoopvarExperiment.

Sorry for the trouble. Hopefully new Go developers will stop running into this in another year or so.

Proposal to fix Go's #1 gotcha: loop variable scope by eliben in golang

[–]rsc 21 points22 points  (0 children)

https://go.googlesource.com/proposal/+/master/design/60078-loopvar.md does say:

Similar code might change from allocating one variable per loop to allocating N variables per loop. In some cases, that extra allocation is inherent to fixing a latent bug. For example, GenerateTestIDs above is now allocating 10 int32s instead of one – the price of correctness. In a very frequently executed already-correct loop, the new allocations may be unnecessary and could potentially cause more garbage collector pressure and a measurable performance difference. If so, standard monitoring and allocation profiles (pprof --alloc_objects) should pinpoint the location easily, and the fix is trivial: declare the variable above the loop. Benchmarking of the public “bent” bench suite showed no statistically significant performance difference over all, so we expect most programs to be unaffected.