You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
764 B
Plaintext
37 lines
764 B
Plaintext
garble build -ldflags='-X=main.unexportedVersion=v1.0.0 -X=test/main/imported.ExportedVar=replaced'
|
|
exec ./main
|
|
cmp stdout main.stdout
|
|
! binsubstr main$exe 'unexportedVersion'
|
|
|
|
[short] stop # no need to verify this with -short
|
|
|
|
exec go build -ldflags='-X=main.unexportedVersion=v1.0.0 -X=test/main/imported.ExportedVar=replaced'
|
|
exec ./main
|
|
cmp stdout main.stdout
|
|
binsubstr main$exe 'unexportedVersion'
|
|
|
|
-- go.mod --
|
|
module test/main
|
|
-- main.go --
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"test/main/imported"
|
|
)
|
|
|
|
var unexportedVersion = "unknown"
|
|
|
|
func main() {
|
|
fmt.Println("version:", unexportedVersion)
|
|
fmt.Println("var:", imported.ExportedVar)
|
|
}
|
|
-- imported/imported.go --
|
|
package imported
|
|
|
|
var ExportedVar = "original"
|
|
-- main.stdout --
|
|
version: v1.0.0
|
|
var: replaced
|