Open
Description
This is special case of #14840, but identified as a potential source of special-cases if the general case is hard to solve.
Compiling the following program:
package main
import "sync"
var initializeVariable = sync.OnceValue(func() string {
return "THIS_IS_DEAD_CODE"
})
func main() {}
should not link in logic for initializeVariable
since the variable is dead.
This also applies to OnceFunc
and OnceValues
.
At present, OnceValue
is unfortunately not a drop-in replacement for for sync.Once
for initializing global variables.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Todo