test/fixedbugs/issue49143.dir/a.go
raw| 1 | // Copyright 2021 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 a |
| 6 | |
| 7 | import "sync" |
| 8 | |
| 9 | type Loader[K comparable, R any] struct { |
| 10 | batch *LoaderBatch[K, R] |
| 11 | } |
| 12 | |
| 13 | func (l *Loader[K, R]) Load() error { |
| 14 | l.batch.f() |
| 15 | return nil |
| 16 | } |
| 17 | |
| 18 | type LoaderBatch[K comparable, R any] struct { |
| 19 | once *sync.Once |
| 20 | } |
| 21 | |
| 22 | func (b *LoaderBatch[K, R]) f() { |
| 23 | b.once.Do(func() {}) |
| 24 | } |