Source file src/cmd/vet/testdata/waitgroup/waitgroup.go

     1  // Copyright 2025 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // This file contains tests for the waitgroup checker.
     6  
     7  package waitgroup
     8  
     9  import "sync"
    10  
    11  func _() {
    12  	var wg *sync.WaitGroup
    13  	wg.Add(1)
    14  	go func() {
    15  		wg.Add(1) // ERROR "WaitGroup.Add called from inside new goroutine"
    16  		defer wg.Done()
    17  		// ...
    18  	}()
    19  	wg.Wait()
    20  }
    21  

View as plain text