...

Source file src/google.golang.org/protobuf/internal/race_test/messageset_extension_init/race_test.go

Documentation: google.golang.org/protobuf/internal/race_test/messageset_extension_init

     1  // Copyright 2024 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  package race_test
     6  
     7  import (
     8  	"sync"
     9  	"testing"
    10  
    11  	epb "google.golang.org/protobuf/internal/testprotos/messageset/msetextpb"
    12  )
    13  
    14  // There must be no other test in this package as we are testing global
    15  // initialization which only happens once per binary.
    16  func TestConcurrentInitialization(t *testing.T) {
    17  	var wg sync.WaitGroup
    18  	wg.Add(2)
    19  	go func() {
    20  		defer wg.Done()
    21  		epb.E_Ext1_MessageSetExtension.ValueOf(&epb.Ext1{})
    22  	}()
    23  	go func() {
    24  		defer wg.Done()
    25  		epb.E_Ext1_MessageSetExtension.TypeDescriptor().Message()
    26  	}()
    27  	wg.Wait()
    28  }
    29  

View as plain text