显然,下划线的权重与文件开头的点前缀相同,并且被go build命令明确忽略。但是,这不是go工具的决定,而是go/build标准库中的软件包的决定。您可以在此处查看负责的行。我的猜测是临时文件带有下划线前缀,因此构建工具链会忽略它们。编辑:此注释记录了行为。我引用:// Import returns details about the Go package named by the import path,// interpreting local import paths relative to the srcDir directory.// If the path is a local import path naming a package that can be imported// using a standard import path, the returned package will set p.ImportPath// to that path.//// In the directory containing the package, .go, .c, .h, and .s files are// considered part of the package except for://// - .go files in package documentation// - files starting with _ or . (likely editor temporary files)// - files with build constraints not satisfied by the context//// If an error occurs, Import returns a non-nil error and a non-nil// *Package containing partial information.//您可以在package的包文档中go/build以用户友好的形式找到它。