Skip to content

runtime error: invalid memory address or nil pointer dereference #12

@oliverpool

Description

@oliverpool

For some reasons, I need to run go t.Run. However this triggers a runtime error: invalid memory address or nil pointer dereference:

package mypackage

import (
	"sync"
	"testing"
)

func TestParallel(t *testing.T) {
	wg := &sync.WaitGroup{}

	wg.Add(1)
	go t.Run("subtest", func(t *testing.T) {
		defer wg.Done()
	})
	wg.Wait()
}

(I test several things that must run in parallel, running t.Parallel my block some of my substests if I have more than GOXMAXPROCS)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions