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.
garble/testdata/scripts/imports.txt

73 lines
1.4 KiB
Plaintext

garble build
exec ./main
cmp stdout main.stdout
! binsubstr main$exe 'ImportedVar' 'ImportedConst' 'ImportedFunc' 'ImportedType' 'main.go' 'imported.go'
binsubstr main$exe 'ImportedAPI'
[short] stop # checking that the build is reproducible is slow
# Also check that the binary is reproducible when many imports are involved.
cp main$exe main_old$exe
rm main$exe
garble build
bincmp main$exe main_old$exe
go build
exec ./main
cmp stdout main.stdout
-- go.mod --
module test/main
-- main.go --
package main
import (
"fmt"
"reflect"
_ "unsafe"
"test/main/imported"
"rsc.io/quote"
)
//go:linkname linkedPrintln fmt.Println
func linkedPrintln(a ...interface{}) (n int, err error)
func main() {
fmt.Println(imported.ImportedVar)
fmt.Println(imported.ImportedConst)
imported.ImportedFunc('x')
fmt.Println(imported.ImportedType(3))
api := new(imported.ImportedAPI)
fmt.Println(reflect.TypeOf(api))
linkedPrintln(nil)
fmt.Println(quote.Go())
}
-- main.stdout --
imported var value
imported const value
3
*imported.ImportedAPI
<nil>
Don't communicate by sharing memory, share memory by communicating.
-- imported/imported.go --
package imported
import "reflect"
var ImportedVar = "imported var value"
const ImportedConst = "imported const value"
func ImportedFunc(param rune) string {
return string(param)
}
type ImportedType int
type ImportedAPI int
var _ = reflect.TypeOf(ImportedAPI(0))