mirror of
https://github.com/burrowers/garble.git
synced 2026-04-22 23:57:14 +08:00
30357af923
This lets us start taking advantage of featurs from Go 1.23, particularly tracking aliases in go/types and iterators. Note that we need to add code to properly handle or skip over the new *types.Alias type which go/types produces for Go type aliases. Also note that we actually turn this mode off entirely for now, due to the bug reported at https://go.dev/issue/70394. We don't yet remove our own alias tracking code yet due to the above. We hope to be able to remove it very soon.
119 lines
1.8 KiB
Plaintext
119 lines
1.8 KiB
Plaintext
exec garble build
|
|
exec ./main
|
|
cmp stdout main.stdout
|
|
|
|
! binsubstr main$exe 'unexportedMethod' 'privateIface'
|
|
|
|
[short] stop # no need to verify this with -short
|
|
|
|
# Check that the program works as expected without garble.
|
|
go build
|
|
exec ./main
|
|
cmp stdout main.stdout
|
|
-- go.mod --
|
|
module test/main
|
|
|
|
go 1.23
|
|
-- main.go --
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"test/main/lib1"
|
|
"test/main/lib2"
|
|
"test/main/lib3"
|
|
)
|
|
|
|
type T string
|
|
|
|
func (t T) String() string {
|
|
return "String method for " + string(t)
|
|
}
|
|
|
|
func (t T) unexportedMethod() string {
|
|
return "unexported method for " + string(t)
|
|
}
|
|
|
|
type privateInterface interface {
|
|
privateIface()
|
|
}
|
|
|
|
func (T) privateIface() {}
|
|
|
|
var _ privateInterface = T("")
|
|
|
|
type StructUnnamed = struct {
|
|
Foo int
|
|
Bar struct {
|
|
Nested *[]string
|
|
}
|
|
Named lib3.Named
|
|
lib3.StructEmbed
|
|
Tagged string // no field tag
|
|
}
|
|
|
|
var _ = lib1.Struct1(lib2.Struct2{})
|
|
|
|
var _ = StructUnnamed(lib2.Struct2{})
|
|
|
|
func main() {
|
|
fmt.Println(T("foo"))
|
|
fmt.Println(T("foo").unexportedMethod())
|
|
}
|
|
|
|
-- main_linux.go --
|
|
package main
|
|
|
|
import "syscall"
|
|
|
|
// golang.org/x/sys/unix has a copy of syscall.Rlimit and converts with it.
|
|
// Note that syscall.Rlimit is only declared in some unix GOOSes.
|
|
type Rlimit2 struct {
|
|
Cur uint64
|
|
Max uint64
|
|
}
|
|
|
|
var _ = (*syscall.Rlimit)(new(Rlimit2))
|
|
|
|
-- lib1/lib1.go --
|
|
package lib1
|
|
|
|
import "test/main/lib3"
|
|
|
|
type Struct1 struct {
|
|
Foo int
|
|
Bar struct {
|
|
Nested *[]string
|
|
}
|
|
Named lib3.Named
|
|
lib3.StructEmbed
|
|
Tagged string `json:"tagged1"`
|
|
}
|
|
|
|
-- lib2/lib2.go --
|
|
package lib2
|
|
|
|
import "test/main/lib3"
|
|
|
|
type Struct2 struct {
|
|
Foo int
|
|
Bar struct {
|
|
Nested *[]string
|
|
}
|
|
Named lib3.Named
|
|
lib3.StructEmbed
|
|
Tagged string `json:"tagged2"`
|
|
}
|
|
-- lib3/lib3.go --
|
|
package lib3
|
|
|
|
type Named int
|
|
|
|
type StructEmbed struct {
|
|
Baz any
|
|
}
|
|
-- main.stdout --
|
|
String method for foo
|
|
unexported method for foo
|