Problem solved!

For some reason I could only reproduce this on my main macOS laptop, but
not on others.  I uninstalled and re-installed Go (using Homebrew) and now
it works.

I have no idea what caused the problem, but I figured I should post the
solution (for what it is) in case anyone else encounters it.

Thanks, Brian and Jason, for trying to repro. Knowing others couldn't repro
the problem pointed me in the right direction.

Best,
Tom


On Tue, Jun 16, 2026 at 4:06 AM 'Brian Candler' via golang-nuts <
[email protected]> wrote:

> On Monday, 15 June 2026 at 23:39:29 UTC+1 Tom Limoncelli wrote:
>
> However when I run this on my personal machine (go1.26.4, Macos 26.5.1)
> the system goes into an infinite loop until I press CTRL-C.
>
>
> I can't reproduce, and my system is similar to yours. I don't know what "
> go-faketime" is, and I wonder if that's the problem. I'm using go
> installed via homebrew.
>
> % go version
> go version go1.26.3 darwin/arm64
> % cat main_test.go
> package main
>
> import (
> "testing"
> )
>
> type MyStruct struct {
> M map[string]string
> }
>
> func MyFunc(b bool) {
> m := &MyStruct{}
> if b {
> m.M["foo"] = "foo" // panic. Uninitialized map!
> } else {
> if m.M == nil {
> m.M = map[string]string{}
> }
> m.M["foo"] = "foo" // no panic
> }
> }
>
> func TestMyFunc(t *testing.T) {
> tests := []struct {
> name string
> data bool
> }{
> {"good", false},
> {"panic", true},
> }
> for _, tt := range tests {
> t.Run(tt.name, func(t *testing.T) {
> MyFunc(tt.data)
> })
> }
> }
> % go mod init example
> go: creating new go.mod: module example
> go: to add module requirements and sums:
> go mod tidy
> % go mod tidy
> % ls -l
> total 16
> -rw-r--r--  1 brian  staff   26 16 Jun 09:00 go.mod
> -rw-r--r--  1 brian  staff  502 16 Jun 09:00 main_test.go
> % go test -v .
> === RUN   TestMyFunc
> === RUN   TestMyFunc/good
> === RUN   TestMyFunc/panic
> --- FAIL: TestMyFunc (0.00s)
>     --- PASS: TestMyFunc/good (0.00s)
>     --- FAIL: TestMyFunc/panic (0.00s)
> panic: assignment to entry in nil map [recovered, repanicked]
>
> goroutine 37 [running]:
> testing.tRunner.func1.2({0x102ea2ca0, 0x102eecc40})
> /opt/homebrew/Cellar/go/1.26.3/libexec/src/testing/testing.go:1974 +0x1a0
> testing.tRunner.func1()
> /opt/homebrew/Cellar/go/1.26.3/libexec/src/testing/testing.go:1977 +0x318
> panic({0x102ea2ca0?, 0x102eecc40?})
> /opt/homebrew/Cellar/go/1.26.3/libexec/src/runtime/panic.go:860 +0x12c
> example.MyFunc(...)
> /Users/brian/tmp/zzz/main_test.go:14
> example.TestMyFunc.func1(0x46a78c0626c8?)
> /Users/brian/tmp/zzz/main_test.go:33 +0x40
> testing.tRunner(0x46a78c0626c8, 0x46a78c030200)
> /opt/homebrew/Cellar/go/1.26.3/libexec/src/testing/testing.go:2036 +0xc4
> created by testing.(*T).Run in goroutine 35
> /opt/homebrew/Cellar/go/1.26.3/libexec/src/testing/testing.go:2101 +0x3a8
> FAIL example 0.218s
> FAIL
>
>
> --
> 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 [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/golang-nuts/e41c06b7-8b1c-42aa-a5c1-2ae2e423a338n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/e41c06b7-8b1c-42aa-a5c1-2ae2e423a338n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/CAHVFxgkSU5iCuqHNMix-trTYW3HjM18QYoHdOb8Rhp9tiX0VmA%40mail.gmail.com.

Reply via email to