[Solved] GoLand 2024.3.1 can not debug unit test and main

### background

```

OS: mac osx: 14.5 (23F79) M1 arm64

GoLand: 2024.3.1

Golang: go version go1.22.1 darwin/arm64

```

### problems

1.  `t.Log("send result", r) ` not working, but remove time.Sleep, it will

2. debug point sometimes ok, sometimes not. 80% not.

3. time.Sleep could be the killer.

i run in main.go, add time.sleep, fmt.println would not work. remove it, then works.

### codes not working

```golang in main.go

m := mockBrokerMessage()
r, _ := messageStoreTest.PutMessage(m)

time.Sleep(2 * time.Second)

fmt.Println("put message success", r)

```

 

```golang in unit test

func TestDefaultMessageStore_QueryByConsumeQueueOffset(t *testing.T) {
    defer func() {
       if r := recover(); r != nil {
          t.Logf("panic recovered: %v", r)
       }
    }()
    m := mockBrokerMessage()
    r, _ := messageStoreTest.PutMessage(m)

    time.Sleep(100 * time.Millisecond)

    t.Log("send result", r)
    if msg, err := messageStoreTest.QueryByConsumeQueueOffset(
       m.Topic,
       m.Queue.QueueId,
       1,
    ); err != nil {
       t.Log("query by consume queue fail", err)
       t.Errorf("query by consume queue fail %v", err)
    } else {
       t.Log("query by consume queue done", util.ToPrettyJsonStringTest(msg))
       assert.True(t, m.Topic == msg.Topic && m.Queue == msg.Queue)
    }

}

```

### i checked

- GOARCH='arm64' OK

- try build latast dlv : dlv.path=/Users/tigerweili/go1.22.1/bin/bin/dlv. NOT WORK

 

0
1 comment

Hi there,

Could you please check if the issue persists in the latest version of our IDE and let me know how it goes? If the problem is still there, please try reproducing it and send us the logs to start the investigation:

1. Add `#com.goide.dlv.DlvVm` in Help | Diagnostic Tools | Debug Log Settings.

2. Restart GoLand.

3. Reproduce the issue with the debugger again to collect the necessary information about your environment.

4. Provide IDE logs via Help | Collect Logs and Diagnostic Data.

 

Thank you!

0

Please sign in to leave a comment.