| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/go/src/cmd/go/testdata/script/ |
Upload File : |
# Without -coverpkg, we should get the same value for a given
# package regardless of how many other packages are selected
# (see issue 65570).
[short] skip
go test -count=1 -cover ./a ./b ./main
stdout '^ok\s+M/main\s+\S+\s+coverage: 75.0% of statements'
go test -count=1 -cover ./main
stdout '^ok\s+M/main\s+\S+\s+coverage: 75.0% of statements'
-- go.mod --
module M
go 1.21
-- a/a.go --
package a
func AFunc() int {
return 42
}
-- b/b.go --
package b
func BFunc() int {
return -42
}
-- main/main.go --
package main
import (
"M/a"
)
func MFunc() string {
return "42"
}
func M2Func() int {
return a.AFunc()
}
func init() {
println("package 'main' init")
}
func main() {
println(a.AFunc())
}
-- main/main_test.go --
package main
import "testing"
func TestMain(t *testing.T) {
if MFunc() != "42" {
t.Fatalf("bad!")
}
if M2Func() != 42 {
t.Fatalf("also bad!")
}
}