|
|
|
env GOPRIVATE=test/main
|
|
|
|
|
|
|
|
garble build
|
|
|
|
exec ./main
|
|
|
|
cmp stderr main.stderr
|
|
|
|
binsubstr main$exe 'privateAdd' 'PublicAdd'
|
|
|
|
|
|
|
|
[short] stop # no need to verify this with -short
|
|
|
|
|
|
|
|
go build
|
|
|
|
exec ./main
|
|
|
|
cmp stderr main.stderr
|
|
|
|
|
|
|
|
-- go.mod --
|
|
|
|
module test/main
|
|
|
|
-- main.go --
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"test/main/imported"
|
|
|
|
)
|
|
|
|
|
|
|
|
func privateAdd(x, y int64) int64
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
println(privateAdd(1, 2))
|
|
|
|
println(imported.PublicAdd(3, 4))
|
|
|
|
}
|
|
|
|
-- main.s --
|
|
|
|
TEXT ·privateAdd(SB),$0-24
|
|
|
|
MOVQ x+0(FP), BX
|
|
|
|
MOVQ y+8(FP), BP
|
|
|
|
ADDQ BP, BX
|
|
|
|
MOVQ BX, ret+16(FP)
|
|
|
|
RET
|
|
|
|
-- imported/imported.go --
|
|
|
|
package imported
|
|
|
|
|
|
|
|
func PublicAdd(x, y int64) int64
|
|
|
|
-- imported/imported.s --
|
|
|
|
TEXT ·PublicAdd(SB),$0-24
|
|
|
|
MOVQ x+0(FP), BX
|
|
|
|
MOVQ y+8(FP), BP
|
|
|
|
ADDQ BP, BX
|
|
|
|
MOVQ BX, ret+16(FP)
|
|
|
|
RET
|
|
|
|
-- main.stderr --
|
|
|
|
3
|
|
|
|
7
|