-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Open
Description
Proposal Details
Some time we want to get the entry info like module name. entry file path, dpendent modules and so on.
before go1.23 these infos can be get from runtime.firstmoduledata, but after go1.23 runtime.firstmoduledata can not be access.
before go1.23
// get path of the entry file, may be a /xx/xx_test.go or /xx/main.go
func getEntryFilePath() string {
mainFile := getMainFile()
if !isTestMode(mainFile) {
return mainFile
}
firstModule := unsafe.Pointer(&firstmoduledata)
fileTab := *(*[]byte)(reflection.Add(firstModule, filetabField.Offset))
lastFiles := getLastFiles(fileTab)
for _, file := range lastFiles {
if isTestFile(file) {
return file
}
}
panic("can not found entry file path")
}Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Incoming