From d7ba47f0d37f5e9a78ecab1ae32f9e5b2b916640 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sat, 29 Aug 2026 20:12:53 +0800 Subject: [PATCH 01/11] support Go 1.27 autocomplete --- _testing/test.0001/out.expected | 20 ++++++++++++++++++-- _testing/test.0019/out.expected | 3 ++- _testing/test.0021/out.expected | 9 +-------- _testing/test.0023/out.expected | 20 ++++++++++++++++++-- _testing/test.0025/out.expected | 5 ++++- _testing/test.0029/out.expected | 20 ++++++++++++++++++-- _testing/test.0036/out.expected | 14 ++++---------- _testing/test.0045/out.expected | 20 ++++++++++++++++++-- _testing/test.0046/out.expected | 20 ++++++++++++++++++-- _testing/test.0048/out.expected | 5 ++++- _testing/test.0057/out.expected | 4 +--- _testing/test.0058/out.expected | 2 +- _testing/test.0059/out.expected | 2 +- ast.go | 21 +++++++++++++++++++++ go.mod | 16 +++++++++++++--- go.sum | 20 ++++++++++++++++---- package.go | 16 ++++++++-------- type_alias_build_hack_18.go | 3 ++- type_alias_build_hack_19.go | 3 ++- types_go118.go | 1 - 20 files changed, 170 insertions(+), 54 deletions(-) diff --git a/_testing/test.0001/out.expected b/_testing/test.0001/out.expected index 662c4e5b..41c26ea4 100644 --- a/_testing/test.0001/out.expected +++ b/_testing/test.0001/out.expected @@ -1,23 +1,39 @@ -Found 25 candidates: - func Errorf(format string, a ...interface{}) error +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string func Fprint(w io.Writer, a ...interface{}) (n int, err error) func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) func Fprintln(w io.Writer, a ...interface{}) (n int, err error) func Fscan(r io.Reader, a ...interface{}) (n int, err error) func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) func Print(a ...interface{}) (n int, err error) func Printf(format string, a ...interface{}) (n int, err error) func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) func Scan(a ...interface{}) (n int, err error) func Scanf(format string, a ...interface{}) (n int, err error) func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() func Sprint(a ...interface{}) string func Sprintf(format string, a ...interface{}) string func Sprintln(a ...interface{}) string func Sscan(str string, a ...interface{}) (n int, err error) func Sscanf(str string, format string, a ...interface{}) (n int, err error) func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) type Formatter interface type GoStringer interface type ScanState interface diff --git a/_testing/test.0019/out.expected b/_testing/test.0019/out.expected index 025e234f..3b6b3000 100644 --- a/_testing/test.0019/out.expected +++ b/_testing/test.0019/out.expected @@ -1,4 +1,4 @@ -Found 15 candidates: +Found 16 candidates: const BestCompression const BestSpeed const DefaultCompression @@ -9,6 +9,7 @@ Found 15 candidates: func NewWriter(w io.Writer) *zlib.Writer func NewWriterLevel(w io.Writer, level int) (*zlib.Writer, error) func NewWriterLevelDict(w io.Writer, level int, dict []byte) (*zlib.Writer, error) + func Reset(r io.Reader, dict []byte) error type Resetter interface type Writer struct var ErrChecksum error diff --git a/_testing/test.0021/out.expected b/_testing/test.0021/out.expected index 883d48ed..25a78e98 100644 --- a/_testing/test.0021/out.expected +++ b/_testing/test.0021/out.expected @@ -1,8 +1 @@ -Found 7 candidates: - func End() token.Pos - func IsExported() bool - func Pos() token.Pos - func String() string - var Name string - var NamePos token.Pos - var Obj *ast.Object +Nothing to complete. diff --git a/_testing/test.0023/out.expected b/_testing/test.0023/out.expected index 662c4e5b..41c26ea4 100644 --- a/_testing/test.0023/out.expected +++ b/_testing/test.0023/out.expected @@ -1,23 +1,39 @@ -Found 25 candidates: - func Errorf(format string, a ...interface{}) error +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string func Fprint(w io.Writer, a ...interface{}) (n int, err error) func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) func Fprintln(w io.Writer, a ...interface{}) (n int, err error) func Fscan(r io.Reader, a ...interface{}) (n int, err error) func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) func Print(a ...interface{}) (n int, err error) func Printf(format string, a ...interface{}) (n int, err error) func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) func Scan(a ...interface{}) (n int, err error) func Scanf(format string, a ...interface{}) (n int, err error) func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() func Sprint(a ...interface{}) string func Sprintf(format string, a ...interface{}) string func Sprintln(a ...interface{}) string func Sscan(str string, a ...interface{}) (n int, err error) func Sscanf(str string, format string, a ...interface{}) (n int, err error) func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) type Formatter interface type GoStringer interface type ScanState interface diff --git a/_testing/test.0025/out.expected b/_testing/test.0025/out.expected index f19058aa..5e0f26c2 100644 --- a/_testing/test.0025/out.expected +++ b/_testing/test.0025/out.expected @@ -1,7 +1,10 @@ -Found 6 candidates: +Found 9 candidates: func Add(ptr Pointer, len IntegerType) Pointer func Alignof(x ArbitraryType) uintptr func Offsetof(x ArbitraryType) uintptr func Sizeof(x ArbitraryType) uintptr func Slice(ptr *ArbitraryType, len IntegerType) []ArbitraryType + func SliceData(slice []ArbitraryType) *ArbitraryType + func String(ptr *byte, len IntegerType) string + func StringData(str string) *byte type Pointer *ArbitraryType diff --git a/_testing/test.0029/out.expected b/_testing/test.0029/out.expected index b8d96ea6..d3293862 100644 --- a/_testing/test.0029/out.expected +++ b/_testing/test.0029/out.expected @@ -1,23 +1,39 @@ -Found 27 candidates: - func Errorf(format string, a ...interface{}) error +Found 43 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string func Fprint(w io.Writer, a ...interface{}) (n int, err error) func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) func Fprintln(w io.Writer, a ...interface{}) (n int, err error) func Fscan(r io.Reader, a ...interface{}) (n int, err error) func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) func Print(a ...interface{}) (n int, err error) func Printf(format string, a ...interface{}) (n int, err error) func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) func Scan(a ...interface{}) (n int, err error) func Scanf(format string, a ...interface{}) (n int, err error) func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() func Sprint(a ...interface{}) string func Sprintf(format string, a ...interface{}) string func Sprintln(a ...interface{}) string func Sscan(str string, a ...interface{}) (n int, err error) func Sscanf(str string, format string, a ...interface{}) (n int, err error) func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) func main() type Formatter interface type GoStringer interface diff --git a/_testing/test.0036/out.expected b/_testing/test.0036/out.expected index 41ebe727..fa6b8bee 100644 --- a/_testing/test.0036/out.expected +++ b/_testing/test.0036/out.expected @@ -1,22 +1,16 @@ -Found 21 candidates: +Found 15 candidates: func Close() error func DWARF() (*dwarf.Data, error) func DynString(tag elf.DynTag) ([]string, error) + func DynValue(tag elf.DynTag) ([]uint64, error) func DynamicSymbols() ([]elf.Symbol, error) + func DynamicVersionNeeds() ([]elf.DynamicVersionNeed, error) + func DynamicVersions() ([]elf.DynamicVersion, error) func ImportedLibraries() ([]string, error) func ImportedSymbols() ([]elf.ImportedSymbol, error) func Section(name string) *elf.Section func SectionByType(typ elf.SectionType) *elf.Section func Symbols() ([]elf.Symbol, error) - var ABIVersion uint8 - var ByteOrder binary.ByteOrder - var Class elf.Class - var Data elf.Data - var Entry uint64 var FileHeader elf.FileHeader - var Machine elf.Machine - var OSABI elf.OSABI var Progs []*elf.Prog var Sections []*elf.Section - var Type elf.Type - var Version elf.Version diff --git a/_testing/test.0045/out.expected b/_testing/test.0045/out.expected index 662c4e5b..41c26ea4 100644 --- a/_testing/test.0045/out.expected +++ b/_testing/test.0045/out.expected @@ -1,23 +1,39 @@ -Found 25 candidates: - func Errorf(format string, a ...interface{}) error +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string func Fprint(w io.Writer, a ...interface{}) (n int, err error) func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) func Fprintln(w io.Writer, a ...interface{}) (n int, err error) func Fscan(r io.Reader, a ...interface{}) (n int, err error) func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) func Print(a ...interface{}) (n int, err error) func Printf(format string, a ...interface{}) (n int, err error) func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) func Scan(a ...interface{}) (n int, err error) func Scanf(format string, a ...interface{}) (n int, err error) func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() func Sprint(a ...interface{}) string func Sprintf(format string, a ...interface{}) string func Sprintln(a ...interface{}) string func Sscan(str string, a ...interface{}) (n int, err error) func Sscanf(str string, format string, a ...interface{}) (n int, err error) func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) type Formatter interface type GoStringer interface type ScanState interface diff --git a/_testing/test.0046/out.expected b/_testing/test.0046/out.expected index 662c4e5b..41c26ea4 100644 --- a/_testing/test.0046/out.expected +++ b/_testing/test.0046/out.expected @@ -1,23 +1,39 @@ -Found 25 candidates: - func Errorf(format string, a ...interface{}) error +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string func Fprint(w io.Writer, a ...interface{}) (n int, err error) func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) func Fprintln(w io.Writer, a ...interface{}) (n int, err error) func Fscan(r io.Reader, a ...interface{}) (n int, err error) func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) func Print(a ...interface{}) (n int, err error) func Printf(format string, a ...interface{}) (n int, err error) func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) func Scan(a ...interface{}) (n int, err error) func Scanf(format string, a ...interface{}) (n int, err error) func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() func Sprint(a ...interface{}) string func Sprintf(format string, a ...interface{}) string func Sprintln(a ...interface{}) string func Sscan(str string, a ...interface{}) (n int, err error) func Sscanf(str string, format string, a ...interface{}) (n int, err error) func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) type Formatter interface type GoStringer interface type ScanState interface diff --git a/_testing/test.0048/out.expected b/_testing/test.0048/out.expected index 1d4f4b4e..797623e0 100644 --- a/_testing/test.0048/out.expected +++ b/_testing/test.0048/out.expected @@ -1,4 +1,7 @@ -Found 7 candidates: +Found 10 candidates: + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string func Fprint(w io.Writer, a ...interface{}) (n int, err error) func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) func Fprintln(w io.Writer, a ...interface{}) (n int, err error) diff --git a/_testing/test.0057/out.expected b/_testing/test.0057/out.expected index 95c340af..25a78e98 100644 --- a/_testing/test.0057/out.expected +++ b/_testing/test.0057/out.expected @@ -1,3 +1 @@ -Found 2 candidates: - func Read(p []byte) (n int, err error) - func Write(p []byte) (n int, err error) +Nothing to complete. diff --git a/_testing/test.0058/out.expected b/_testing/test.0058/out.expected index 81c23c96..89e93e1b 100644 --- a/_testing/test.0058/out.expected +++ b/_testing/test.0058/out.expected @@ -1,2 +1,2 @@ Found 1 candidates: - func NewPackage(fset *token.FileSet, files map[string]*myast.File, importer myast.Importer, universe *myast.Scope) (*myast.Package, error) + func NewPackage(fset *token.FileSet, files map[string]*ast.File, importer ast.Importer, universe *ast.Scope) (*ast.Package, error) diff --git a/_testing/test.0059/out.expected b/_testing/test.0059/out.expected index abfde3a3..3bf8bfb2 100644 --- a/_testing/test.0059/out.expected +++ b/_testing/test.0059/out.expected @@ -1,2 +1,2 @@ Found 1 candidates: - func NewReader(r myio.Reader) myio.Reader + func NewReader(r io.Reader) io.Reader diff --git a/ast.go b/ast.go index 5f9862b0..d9139aca 100644 --- a/ast.go +++ b/ast.go @@ -119,6 +119,10 @@ func toType(pkg *types.Package, typ types.Type) ast.Expr { return &ast.StarExpr{X: toType(pkg, t.Elem())} case *types.Named: return toNamedType(pkg, t) + case *types.Alias: + return toType(pkg, t.Rhs()) + case *types.Union: + return toUnionType(pkg, t) case *types.Interface: return toInterface(pkg, t) case *types.Slice: @@ -140,6 +144,23 @@ func toType(pkg *types.Package, typ types.Type) ast.Expr { return nil } +func toUnionType(pkg *types.Package, t *types.Union) ast.Expr { + var expr ast.Expr + for i := 0; i < t.Len(); i++ { + term := t.Term(i) + item := toType(pkg, term.Type()) + if term.Tilde() { + item = &ast.UnaryExpr{Op: TILDE, X: item} + } + if expr == nil { + expr = item + } else { + expr = &ast.BinaryExpr{X: expr, Op: token.OR, Y: item} + } + } + return expr +} + func toObjectExpr(pkg *types.Package, v types.Object) ast.Expr { vpkg, name := v.Pkg(), v.Name() if vpkg == nil || vpkg == g_daemon.autocomplete.typesPkg { // at universe or at this package diff --git a/go.mod b/go.mod index ae16e170..8d7c5265 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,18 @@ module github.com/visualfc/gocode -go 1.13 +go 1.25.0 require ( - github.com/visualfc/gotools v1.5.3 - golang.org/x/tools v0.5.0 + github.com/visualfc/gotools v1.5.5-0.20260829095928-37d050d3eb58 + golang.org/x/tools v0.49.0 +) + +require ( + github.com/creack/pty v1.1.21 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/visualfc/gomod v0.1.2 // indirect + github.com/visualfc/goversion v1.1.0 // indirect + github.com/yuin/goldmark v1.4.13 // indirect + golang.org/x/mod v0.39.0 // indirect + golang.org/x/sync v0.22.0 // indirect ) diff --git a/go.sum b/go.sum index a7ae3a19..7751c0e6 100644 --- a/go.sum +++ b/go.sum @@ -1,30 +1,41 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0= +github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/visualfc/gomod v0.1.2 h1:7qfPmifcA8r/0ZTpTPZQqsm5aJUiQ/EeyHEENPyywDg= github.com/visualfc/gomod v0.1.2/go.mod h1:rV5goiA/Ul6yT8X2eDnc/dl0dVy0cDHJLZVOuJ8PdmM= github.com/visualfc/gotools v1.5.3 h1:22TyNM6i+/psP07vjveWy6PhhMGNtwWEbDL8PrW4jms= github.com/visualfc/gotools v1.5.3/go.mod h1:VlP59ccCsSmRbFZTbuHgQDrTOi40EGKvyFK2Cq2Far8= +github.com/visualfc/gotools v1.5.4 h1:ydm1Kb+UCylRxOCKjWjC9sXQfvQG8/khxygzLwnORDc= +github.com/visualfc/gotools v1.5.4/go.mod h1:VlP59ccCsSmRbFZTbuHgQDrTOi40EGKvyFK2Cq2Far8= +github.com/visualfc/gotools v1.5.5-0.20260829095928-37d050d3eb58 h1:GpU5lDGZA2gegH0HMI6NtDi2l+05dislHJ6RaceX+RQ= +github.com/visualfc/gotools v1.5.5-0.20260829095928-37d050d3eb58/go.mod h1:ymCj4CUbObE6C/PBz4DqF8AoI53GRnSu99JfxDf4htI= +github.com/visualfc/goversion v1.1.0 h1:EN0YQGRkeGoWTPxPNTnbhyNQyas5leKH5U5lL4t8lRE= github.com/visualfc/goversion v1.1.0/go.mod h1:Gr3s6bW8NTomhheImwAttqno97Mw6pAnFn2dU8/EMa8= +github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.39.0 h1:UF5zwQdCRRUpHfyPwr7d4UrGiVeldIsogtzWVnczL74= +golang.org/x/mod v0.39.0/go.mod h1:bvIbwjQ0HUFFf5AKukeeYQG4ZBUG9yxQbR9aEweIwYY= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -36,6 +47,7 @@ golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4= golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= +golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI= +golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/package.go b/package.go index 516cb9b4..daae517d 100644 --- a/package.go +++ b/package.go @@ -9,7 +9,6 @@ import ( "log" "strings" - "github.com/visualfc/gocode/internal/gcexportdata" "golang.org/x/tools/go/types/typeutil" ) @@ -219,17 +218,15 @@ func (m *package_file_cache) process_package_types(c *auto_complete_context, pkg // create map for other packages m.others = make(map[string]*decl) - var pp package_parser - fset := token.NewFileSet() - var buf bytes.Buffer - gcexportdata.Write(&buf, fset, pkg) - var p gc_bin_parser - p.init(buf.Bytes(), m) - pp = &p + var pp types_export + pp.init(pkg, m) prefix := "!" + m.name + "!" //log.Println("load pkg", pkg.Path(), pkg.Imports()) pp.parse_export(func(pkg string, decl ast.Decl) { + if decl == nil { + return + } anonymify_ast(decl, decl_foreign, m.scope) if pkg == "" || strings.HasPrefix(pkg, prefix) { // main package @@ -332,6 +329,9 @@ func (m *package_file_cache) process_package_data(c *auto_complete_context, data prefix := "!" + m.name + "!" pp.parse_export(func(pkg string, decl ast.Decl) { + if decl == nil { + return + } anonymify_ast(decl, decl_foreign, m.scope) if pkg == "" || strings.HasPrefix(pkg, prefix) { // main package diff --git a/type_alias_build_hack_18.go b/type_alias_build_hack_18.go index cb7d1f13..526510b3 100644 --- a/type_alias_build_hack_18.go +++ b/type_alias_build_hack_18.go @@ -1,4 +1,5 @@ -// +build !go1.9,!go1.8.typealias +//go:build !go1.9 +// +build !go1.9 package main diff --git a/type_alias_build_hack_19.go b/type_alias_build_hack_19.go index b2b074f5..5b04c4c6 100644 --- a/type_alias_build_hack_19.go +++ b/type_alias_build_hack_19.go @@ -1,4 +1,5 @@ -// +build go1.9 go1.8.typealias +//go:build go1.9 +// +build go1.9 package main diff --git a/types_go118.go b/types_go118.go index 25618134..c7daca8c 100644 --- a/types_go118.go +++ b/types_go118.go @@ -208,7 +208,6 @@ func lookup_types_near_instance(ident *ast.Ident, pos token.Pos, info *types.Inf }) return ar[0].typ } - return nil } func DefaultPkgConfig() *pkgwalk.PkgConfig { From 9f7ddb51dd842d2bc67efdc45ae6b9ceb9a44652 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sat, 29 Aug 2026 20:21:33 +0800 Subject: [PATCH 02/11] fix Go 1.27 method completion --- _testing/test.0011/out.expected | 37 ++++++++++++++++++++++++++++++++- autocompletecontext.go | 13 ++++++++++++ package.go | 2 ++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/_testing/test.0011/out.expected b/_testing/test.0011/out.expected index 03c24f8d..40c225e7 100644 --- a/_testing/test.0011/out.expected +++ b/_testing/test.0011/out.expected @@ -1,4 +1,4 @@ -Found 70 candidates: +Found 105 candidates: func Addr() reflect.Value func Bool() bool func Bytes() []byte @@ -13,16 +13,21 @@ Found 70 candidates: func CanSet() bool func CanUint() bool func Cap() int + func Clear() func Close() + func Comparable() (#rv1 bool) func Complex() complex128 func Convert(t reflect.Type) reflect.Value func Elem() reflect.Value + func Equal(u reflect.Value) bool func Field(i int) reflect.Value func FieldByIndex(index []int) reflect.Value func FieldByIndexErr(index []int) (reflect.Value, error) func FieldByName(name string) reflect.Value func FieldByNameFunc(match func(string) bool) reflect.Value + func Fields() (iter.Seq2[reflect.StructField, reflect.Value]) func Float() float64 + func Grow(n int) func Index(i int) reflect.Value func Int() int64 func Interface() (i interface{}) @@ -37,6 +42,7 @@ Found 70 candidates: func MapRange() *reflect.MapIter func Method(i int) reflect.Value func MethodByName(name string) reflect.Value + func Methods() (iter.Seq2[reflect.Method, reflect.Value]) func NumField() int func NumMethod() int func OverflowComplex(x complex128) bool @@ -46,6 +52,8 @@ Found 70 candidates: func Pointer() uintptr func Recv() (x reflect.Value, ok bool) func Send(x reflect.Value) + func Seq() iter.Seq[reflect.Value] + func Seq2() (iter.Seq2[reflect.Value, reflect.Value]) func Set(x reflect.Value) func SetBool(x bool) func SetBytes(x []byte) @@ -60,6 +68,7 @@ Found 70 candidates: func SetPointer(x unsafe.Pointer) func SetString(x string) func SetUint(x uint64) + func SetZero() func Slice(i int, j int) reflect.Value func Slice3(i int, j int, k int) reflect.Value func String() string @@ -69,3 +78,29 @@ Found 70 candidates: func Uint() uint64 func UnsafeAddr() uintptr func UnsafePointer() unsafe.Pointer + func abiType() *abi.Type + func abiTypeSlow() *abi.Type + func assignTo(context string, dst *abi.Type, target unsafe.Pointer) reflect.Value + func bytesSlow() []byte + func call(op string, in []reflect.Value) []reflect.Value + func capNonSlice() int + func extendSlice(n int) reflect.Value + func grow(n int) + func kind() reflect.Kind + func lenNonSlice() int + func mustBe(expected reflect.Kind) + func mustBeAssignable() + func mustBeAssignableSlow() + func mustBeExported() + func mustBeExportedSlow() + func panicNotBool() + func panicNotMap() + func pointer() unsafe.Pointer + func recv(nb bool) (val reflect.Value, ok bool) + func ro() reflect.flag + func runes() []rune + func send(x reflect.Value, nb bool) (selected bool) + func setRunes(x []rune) + func stringNonString() string + func typ() *abi.Type + func typeSlow() reflect.Type diff --git a/autocompletecontext.go b/autocompletecontext.go index 64bddc50..f76eb928 100644 --- a/autocompletecontext.go +++ b/autocompletecontext.go @@ -272,6 +272,19 @@ func (c *auto_complete_context) decl_package_import_path(decl *decl) string { } func (c *auto_complete_context) get_candidates_from_decl(cc cursor_context, class decl_class, b *out_buffers) { + // Some newer export/type-check paths produce a declaration without the + // method children attached. Recover the method set directly from go/types. + if len(cc.decl.children) == 0 { + if typ := c.lookup_ident(cc.expr); typ != nil { + if named, ok := typ.(*types.Named); ok { + for _, sel := range typeutil.IntuitiveMethodSet(named, nil) { + sig := sel.Type().(*types.Signature) + method := new_decl_full(sel.Obj().Name(), decl_func, decl_foreign, toType(sel.Obj().Pkg(), sig), nil, -1, cc.decl.scope) + b.append_decl(cc.partial, method.name, c.decl_package_import_path(cc.decl), method, class) + } + } + } + } if cc.decl.is_alias() { c.get_candidates_from_decl_alias(cc, class, b) return diff --git a/package.go b/package.go index daae517d..baf6a40e 100644 --- a/package.go +++ b/package.go @@ -186,6 +186,7 @@ func pkg_parse_export(pkg *types.Package, pfc *package_file_cache, callback func Tok: token.TYPE, Specs: []ast.Spec{toTypeSpec(pkg, t)}, } + callback(pkgid, decl) if named, ok := t.Type().(*types.Named); ok { for _, sel := range typeutil.IntuitiveMethodSet(named, nil) { sig := sel.Type().(*types.Signature) @@ -197,6 +198,7 @@ func pkg_parse_export(pkg *types.Package, pfc *package_file_cache, callback func callback(pkgid, decl) } } + continue case *types.Func: sig := t.Type().(*types.Signature) decl = &ast.FuncDecl{ From be169133ca54acb088f98d097ac3efcc60ad7067 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sat, 29 Aug 2026 20:51:47 +0800 Subject: [PATCH 03/11] add comprehensive generic completion tests --- _testing/DESC | 20 ++++++++++++++++++++ _testing/test.0064/cursor.87 | 0 _testing/test.0064/out.expected | 2 ++ _testing/test.0064/test.go.in | 8 ++++++++ _testing/test.0065/cursor.107 | 0 _testing/test.0065/out.expected | 1 + _testing/test.0065/test.go.in | 8 ++++++++ _testing/test.0066/cursor.165 | 0 _testing/test.0066/out.expected | 2 ++ _testing/test.0066/test.go.in | 10 ++++++++++ _testing/test.0067/cursor.175 | 0 _testing/test.0067/out.expected | 1 + _testing/test.0067/test.go.in | 10 ++++++++++ _testing/test.0068/cursor.208 | 0 _testing/test.0068/out.expected | 4 ++++ _testing/test.0068/test.go.in | 10 ++++++++++ _testing/test.0069/cursor.112 | 0 _testing/test.0069/out.expected | 3 +++ _testing/test.0069/test.go.in | 8 ++++++++ _testing/test.0070/cursor.131 | 0 _testing/test.0070/out.expected | 1 + _testing/test.0070/test.go.in | 8 ++++++++ _testing/test.0071/cursor.150 | 0 _testing/test.0071/out.expected | 2 ++ _testing/test.0071/test.go.in | 9 +++++++++ _testing/test.0072/cursor.175 | 0 _testing/test.0072/out.expected | 4 ++++ _testing/test.0072/test.go.in | 10 ++++++++++ _testing/test.0073/cursor.195 | 0 _testing/test.0073/out.expected | 4 ++++ _testing/test.0073/test.go.in | 9 +++++++++ _testing/test.0074/cursor.214 | 0 _testing/test.0074/out.expected | 2 ++ _testing/test.0074/test.go.in | 11 +++++++++++ _testing/test.0075/cursor.122 | 0 _testing/test.0075/out.expected | 3 +++ _testing/test.0075/test.go.in | 9 +++++++++ _testing/test.0076/cursor.194 | 0 _testing/test.0076/out.expected | 3 +++ _testing/test.0076/test.go.in | 9 +++++++++ _testing/test.0077/cursor.145 | 0 _testing/test.0077/out.expected | 2 ++ _testing/test.0077/test.go.in | 9 +++++++++ _testing/test.0078/cursor.183 | 0 _testing/test.0078/out.expected | 4 ++++ _testing/test.0078/test.go.in | 9 +++++++++ _testing/test.0079/cursor.167 | 0 _testing/test.0079/out.expected | 2 ++ _testing/test.0079/test.go.in | 9 +++++++++ _testing/test.0080/cursor.209 | 0 _testing/test.0080/out.expected | 3 +++ _testing/test.0080/test.go.in | 10 ++++++++++ _testing/test.0081/cursor.134 | 0 _testing/test.0081/out.expected | 3 +++ _testing/test.0081/out.expected.go1.26 | 3 +++ _testing/test.0081/out.expected.go1.27 | 3 +++ _testing/test.0081/test.go.in | 9 +++++++++ _testing/test.0082/cursor.204 | 0 _testing/test.0082/out.expected | 3 +++ _testing/test.0082/out.expected.go1.26 | 3 +++ _testing/test.0082/out.expected.go1.27 | 3 +++ _testing/test.0082/test.go.in | 10 ++++++++++ _testing/test.0083/cursor.196 | 0 _testing/test.0083/out.expected | 4 ++++ _testing/test.0083/out.expected.go1.26 | 4 ++++ _testing/test.0083/out.expected.go1.27 | 4 ++++ _testing/test.0083/test.go.in | 9 +++++++++ 67 files changed, 277 insertions(+) create mode 100644 _testing/test.0064/cursor.87 create mode 100644 _testing/test.0064/out.expected create mode 100644 _testing/test.0064/test.go.in create mode 100644 _testing/test.0065/cursor.107 create mode 100644 _testing/test.0065/out.expected create mode 100644 _testing/test.0065/test.go.in create mode 100644 _testing/test.0066/cursor.165 create mode 100644 _testing/test.0066/out.expected create mode 100644 _testing/test.0066/test.go.in create mode 100644 _testing/test.0067/cursor.175 create mode 100644 _testing/test.0067/out.expected create mode 100644 _testing/test.0067/test.go.in create mode 100644 _testing/test.0068/cursor.208 create mode 100644 _testing/test.0068/out.expected create mode 100644 _testing/test.0068/test.go.in create mode 100644 _testing/test.0069/cursor.112 create mode 100644 _testing/test.0069/out.expected create mode 100644 _testing/test.0069/test.go.in create mode 100644 _testing/test.0070/cursor.131 create mode 100644 _testing/test.0070/out.expected create mode 100644 _testing/test.0070/test.go.in create mode 100644 _testing/test.0071/cursor.150 create mode 100644 _testing/test.0071/out.expected create mode 100644 _testing/test.0071/test.go.in create mode 100644 _testing/test.0072/cursor.175 create mode 100644 _testing/test.0072/out.expected create mode 100644 _testing/test.0072/test.go.in create mode 100644 _testing/test.0073/cursor.195 create mode 100644 _testing/test.0073/out.expected create mode 100644 _testing/test.0073/test.go.in create mode 100644 _testing/test.0074/cursor.214 create mode 100644 _testing/test.0074/out.expected create mode 100644 _testing/test.0074/test.go.in create mode 100644 _testing/test.0075/cursor.122 create mode 100644 _testing/test.0075/out.expected create mode 100644 _testing/test.0075/test.go.in create mode 100644 _testing/test.0076/cursor.194 create mode 100644 _testing/test.0076/out.expected create mode 100644 _testing/test.0076/test.go.in create mode 100644 _testing/test.0077/cursor.145 create mode 100644 _testing/test.0077/out.expected create mode 100644 _testing/test.0077/test.go.in create mode 100644 _testing/test.0078/cursor.183 create mode 100644 _testing/test.0078/out.expected create mode 100644 _testing/test.0078/test.go.in create mode 100644 _testing/test.0079/cursor.167 create mode 100644 _testing/test.0079/out.expected create mode 100644 _testing/test.0079/test.go.in create mode 100644 _testing/test.0080/cursor.209 create mode 100644 _testing/test.0080/out.expected create mode 100644 _testing/test.0080/test.go.in create mode 100644 _testing/test.0081/cursor.134 create mode 100644 _testing/test.0081/out.expected create mode 100644 _testing/test.0081/out.expected.go1.26 create mode 100644 _testing/test.0081/out.expected.go1.27 create mode 100644 _testing/test.0081/test.go.in create mode 100644 _testing/test.0082/cursor.204 create mode 100644 _testing/test.0082/out.expected create mode 100644 _testing/test.0082/out.expected.go1.26 create mode 100644 _testing/test.0082/out.expected.go1.27 create mode 100644 _testing/test.0082/test.go.in create mode 100644 _testing/test.0083/cursor.196 create mode 100644 _testing/test.0083/out.expected create mode 100644 _testing/test.0083/out.expected.go1.26 create mode 100644 _testing/test.0083/out.expected.go1.27 create mode 100644 _testing/test.0083/test.go.in diff --git a/_testing/DESC b/_testing/DESC index c81a38a6..229f1d78 100644 --- a/_testing/DESC +++ b/_testing/DESC @@ -61,3 +61,23 @@ test.0060 - shortcut syntax for return value types in functions test.0061 - function body vs struct literal cursor context detection test.0062 - struct type alias embedding test.0063 - fields autocompletion for a struct literal which is defined by a type alias +test.0064 - generic struct field completion +test.0065 - generic function instantiation result +test.0066 - generic function interface constraint +test.0067 - union type constraint +test.0068 - generic methods with receiver type parameters +test.0069 - multiple type parameters and instantiated struct +test.0070 - generic function with multiple type parameters +test.0071 - generic type inference from function result +test.0072 - generic value and pointer methods +test.0073 - instantiated multi-parameter pointer method +test.0074 - generic interface constraint implementation +test.0075 - embedded instantiated generic type +test.0076 - generic function inferred struct result +test.0077 - nested instantiated generic fields +test.0078 - multi-parameter generic method +test.0079 - generic slice field instantiation +test.0080 - constrained generic method +test.0081 - Go 1.27 generic method type parameter +test.0082 - generic method returning instantiated generic type +test.0083 - generic method with multiple own type parameters diff --git a/_testing/test.0064/cursor.87 b/_testing/test.0064/cursor.87 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0064/out.expected b/_testing/test.0064/out.expected new file mode 100644 index 00000000..e1da1cec --- /dev/null +++ b/_testing/test.0064/out.expected @@ -0,0 +1,2 @@ +Found 1 candidates: + var Value int diff --git a/_testing/test.0064/test.go.in b/_testing/test.0064/test.go.in new file mode 100644 index 00000000..dda98054 --- /dev/null +++ b/_testing/test.0064/test.go.in @@ -0,0 +1,8 @@ +package main + +type Box[T any] struct { Value T } + +func main() { + var box Box[int] + box. +} diff --git a/_testing/test.0065/cursor.107 b/_testing/test.0065/cursor.107 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0065/out.expected b/_testing/test.0065/out.expected new file mode 100644 index 00000000..25a78e98 --- /dev/null +++ b/_testing/test.0065/out.expected @@ -0,0 +1 @@ +Nothing to complete. diff --git a/_testing/test.0065/test.go.in b/_testing/test.0065/test.go.in new file mode 100644 index 00000000..4d6c8df4 --- /dev/null +++ b/_testing/test.0065/test.go.in @@ -0,0 +1,8 @@ +package main + +func Identity[T any](v T) T { return v } + +func main() { + var value = Identity[int](1) + value. +} diff --git a/_testing/test.0066/cursor.165 b/_testing/test.0066/cursor.165 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0066/out.expected b/_testing/test.0066/out.expected new file mode 100644 index 00000000..a43fdbd0 --- /dev/null +++ b/_testing/test.0066/out.expected @@ -0,0 +1,2 @@ +Found 1 candidates: + func String() string diff --git a/_testing/test.0066/test.go.in b/_testing/test.0066/test.go.in new file mode 100644 index 00000000..29e3af63 --- /dev/null +++ b/_testing/test.0066/test.go.in @@ -0,0 +1,10 @@ +package main + +type Named struct{} +func (Named) String() string { return "" } +func Use[T interface{ String() string }](v T) {} + +func main() { + var value Named + value. +} diff --git a/_testing/test.0067/cursor.175 b/_testing/test.0067/cursor.175 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0067/out.expected b/_testing/test.0067/out.expected new file mode 100644 index 00000000..25a78e98 --- /dev/null +++ b/_testing/test.0067/out.expected @@ -0,0 +1 @@ +Nothing to complete. diff --git a/_testing/test.0067/test.go.in b/_testing/test.0067/test.go.in new file mode 100644 index 00000000..00764c2b --- /dev/null +++ b/_testing/test.0067/test.go.in @@ -0,0 +1,10 @@ +package main + +type Number interface { ~int | ~float64 } +type MyInt int +func Max[T Number](a, b T) T { if a > b { return a }; return b } + +func main() { + var value MyInt + value. +} diff --git a/_testing/test.0068/cursor.208 b/_testing/test.0068/cursor.208 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0068/out.expected b/_testing/test.0068/out.expected new file mode 100644 index 00000000..cae34ee4 --- /dev/null +++ b/_testing/test.0068/out.expected @@ -0,0 +1,4 @@ +Found 3 candidates: + func Pop() int + func Push(v int) + var items []int diff --git a/_testing/test.0068/test.go.in b/_testing/test.0068/test.go.in new file mode 100644 index 00000000..0e8f2229 --- /dev/null +++ b/_testing/test.0068/test.go.in @@ -0,0 +1,10 @@ +package main + +type Stack[T any] struct { items []T } +func (s *Stack[T]) Push(v T) { s.items = append(s.items, v) } +func (s *Stack[T]) Pop() T { return s.items[0] } + +func main() { + var stack Stack[int] + stack. +} diff --git a/_testing/test.0069/cursor.112 b/_testing/test.0069/cursor.112 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0069/out.expected b/_testing/test.0069/out.expected new file mode 100644 index 00000000..c7ae96a6 --- /dev/null +++ b/_testing/test.0069/out.expected @@ -0,0 +1,3 @@ +Found 2 candidates: + var First int + var Second string diff --git a/_testing/test.0069/test.go.in b/_testing/test.0069/test.go.in new file mode 100644 index 00000000..e95c0f47 --- /dev/null +++ b/_testing/test.0069/test.go.in @@ -0,0 +1,8 @@ +package main + +type Pair[A, B any] struct { First A; Second B } + +func main() { + var pair Pair[int, string] + pair. +} diff --git a/_testing/test.0070/cursor.131 b/_testing/test.0070/cursor.131 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0070/out.expected b/_testing/test.0070/out.expected new file mode 100644 index 00000000..25a78e98 --- /dev/null +++ b/_testing/test.0070/out.expected @@ -0,0 +1 @@ +Nothing to complete. diff --git a/_testing/test.0070/test.go.in b/_testing/test.0070/test.go.in new file mode 100644 index 00000000..f800be30 --- /dev/null +++ b/_testing/test.0070/test.go.in @@ -0,0 +1,8 @@ +package main + +func Convert[T, U any](v T) U { var zero U; return zero } + +func main() { + var value = Convert[int, string](1) + value. +} diff --git a/_testing/test.0071/cursor.150 b/_testing/test.0071/cursor.150 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0071/out.expected b/_testing/test.0071/out.expected new file mode 100644 index 00000000..a4738e96 --- /dev/null +++ b/_testing/test.0071/out.expected @@ -0,0 +1,2 @@ +Found 1 candidates: + var Value string diff --git a/_testing/test.0071/test.go.in b/_testing/test.0071/test.go.in new file mode 100644 index 00000000..e64fc069 --- /dev/null +++ b/_testing/test.0071/test.go.in @@ -0,0 +1,9 @@ +package main + +type Box[T any] struct { Value T } +func Make[T any](v T) Box[T] { return Box[T]{Value: v} } + +func main() { + var box = Make("text") + box. +} diff --git a/_testing/test.0072/cursor.175 b/_testing/test.0072/cursor.175 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0072/out.expected b/_testing/test.0072/out.expected new file mode 100644 index 00000000..3ab18393 --- /dev/null +++ b/_testing/test.0072/out.expected @@ -0,0 +1,4 @@ +Found 3 candidates: + func Get() string + func Set(v string) + var value string diff --git a/_testing/test.0072/test.go.in b/_testing/test.0072/test.go.in new file mode 100644 index 00000000..aac46865 --- /dev/null +++ b/_testing/test.0072/test.go.in @@ -0,0 +1,10 @@ +package main + +type Bag[T any] struct { value T } +func (b Bag[T]) Get() T { return b.value } +func (b *Bag[T]) Set(v T) { b.value = v } + +func main() { + var bag Bag[string] + bag. +} diff --git a/_testing/test.0073/cursor.195 b/_testing/test.0073/cursor.195 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0073/out.expected b/_testing/test.0073/out.expected new file mode 100644 index 00000000..2a47c637 --- /dev/null +++ b/_testing/test.0073/out.expected @@ -0,0 +1,4 @@ +Found 3 candidates: + func Swap() (Pair[string, int]) + var First int + var Second string diff --git a/_testing/test.0073/test.go.in b/_testing/test.0073/test.go.in new file mode 100644 index 00000000..0fa2c5e5 --- /dev/null +++ b/_testing/test.0073/test.go.in @@ -0,0 +1,9 @@ +package main + +type Pair[A, B any] struct { First A; Second B } +func (p *Pair[A, B]) Swap() Pair[B, A] { return Pair[B, A]{p.Second, p.First} } + +func main() { + var pair Pair[int, string] + (&pair). +} diff --git a/_testing/test.0074/cursor.214 b/_testing/test.0074/cursor.214 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0074/out.expected b/_testing/test.0074/out.expected new file mode 100644 index 00000000..3a560db4 --- /dev/null +++ b/_testing/test.0074/out.expected @@ -0,0 +1,2 @@ +Found 1 candidates: + func Read() int diff --git a/_testing/test.0074/test.go.in b/_testing/test.0074/test.go.in new file mode 100644 index 00000000..e8e6a8bf --- /dev/null +++ b/_testing/test.0074/test.go.in @@ -0,0 +1,11 @@ +package main + +type Reader[T any] interface { Read() T } +type Source struct{} +func (Source) Read() int { return 0 } +func Consume[T Reader[int]](r T) int { return r.Read() } + +func main() { + var source Source + source. +} diff --git a/_testing/test.0075/cursor.122 b/_testing/test.0075/cursor.122 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0075/out.expected b/_testing/test.0075/out.expected new file mode 100644 index 00000000..09cc91f6 --- /dev/null +++ b/_testing/test.0075/out.expected @@ -0,0 +1,3 @@ +Found 2 candidates: + var Base Base[int] + var ID int diff --git a/_testing/test.0075/test.go.in b/_testing/test.0075/test.go.in new file mode 100644 index 00000000..3be5be85 --- /dev/null +++ b/_testing/test.0075/test.go.in @@ -0,0 +1,9 @@ +package main + +type Base[T any] struct { ID T } +type Derived struct { Base[int] } + +func main() { + var value Derived + value. +} diff --git a/_testing/test.0076/cursor.194 b/_testing/test.0076/cursor.194 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0076/out.expected b/_testing/test.0076/out.expected new file mode 100644 index 00000000..1cbb285a --- /dev/null +++ b/_testing/test.0076/out.expected @@ -0,0 +1,3 @@ +Found 2 candidates: + var Data int + var Valid bool diff --git a/_testing/test.0076/test.go.in b/_testing/test.0076/test.go.in new file mode 100644 index 00000000..e8e79a56 --- /dev/null +++ b/_testing/test.0076/test.go.in @@ -0,0 +1,9 @@ +package main + +type Result[T any] struct { Data T; Valid bool } +func NewResult[T any](v T) Result[T] { return Result[T]{Data: v, Valid: true} } + +func main() { + var result = NewResult(42) + result. +} diff --git a/_testing/test.0077/cursor.145 b/_testing/test.0077/cursor.145 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0077/out.expected b/_testing/test.0077/out.expected new file mode 100644 index 00000000..883a71c1 --- /dev/null +++ b/_testing/test.0077/out.expected @@ -0,0 +1,2 @@ +Found 1 candidates: + var Value float64 diff --git a/_testing/test.0077/test.go.in b/_testing/test.0077/test.go.in new file mode 100644 index 00000000..f61d502c --- /dev/null +++ b/_testing/test.0077/test.go.in @@ -0,0 +1,9 @@ +package main + +type Matrix[T any] struct { Value T } +type Grid[T any] struct { Cell Matrix[T] } + +func main() { + var grid Grid[float64] + grid.Cell. +} diff --git a/_testing/test.0078/cursor.183 b/_testing/test.0078/cursor.183 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0078/out.expected b/_testing/test.0078/out.expected new file mode 100644 index 00000000..ec40bc00 --- /dev/null +++ b/_testing/test.0078/out.expected @@ -0,0 +1,4 @@ +Found 3 candidates: + func Convert(v int) string + var From int + var To string diff --git a/_testing/test.0078/test.go.in b/_testing/test.0078/test.go.in new file mode 100644 index 00000000..728c9830 --- /dev/null +++ b/_testing/test.0078/test.go.in @@ -0,0 +1,9 @@ +package main + +type Converter[A, B any] struct { From A; To B } +func (c Converter[A, B]) Convert(v A) B { return c.To } + +func main() { + var converter Converter[int, string] + converter. +} diff --git a/_testing/test.0079/cursor.167 b/_testing/test.0079/cursor.167 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0079/out.expected b/_testing/test.0079/out.expected new file mode 100644 index 00000000..3cf033aa --- /dev/null +++ b/_testing/test.0079/out.expected @@ -0,0 +1,2 @@ +Found 1 candidates: + var Value []string diff --git a/_testing/test.0079/test.go.in b/_testing/test.0079/test.go.in new file mode 100644 index 00000000..027ae6c7 --- /dev/null +++ b/_testing/test.0079/test.go.in @@ -0,0 +1,9 @@ +package main + +type Option[T any] struct { Value T } +func Some[T any](v T) Option[T] { return Option[T]{Value: v} } + +func main() { + var option Option[[]string] + option. +} diff --git a/_testing/test.0080/cursor.209 b/_testing/test.0080/cursor.209 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0080/out.expected b/_testing/test.0080/out.expected new file mode 100644 index 00000000..b2cfa759 --- /dev/null +++ b/_testing/test.0080/out.expected @@ -0,0 +1,3 @@ +Found 2 candidates: + func ValueOf() string + var Value string diff --git a/_testing/test.0080/test.go.in b/_testing/test.0080/test.go.in new file mode 100644 index 00000000..6fcc2138 --- /dev/null +++ b/_testing/test.0080/test.go.in @@ -0,0 +1,10 @@ +package main + +type Constraint interface { ~int | ~string } +type Wrapper[T Constraint] struct { Value T } +func (w Wrapper[T]) ValueOf() T { return w.Value } + +func main() { + var wrapper Wrapper[string] + wrapper. +} diff --git a/_testing/test.0081/cursor.134 b/_testing/test.0081/cursor.134 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0081/out.expected b/_testing/test.0081/out.expected new file mode 100644 index 00000000..d1d87022 --- /dev/null +++ b/_testing/test.0081/out.expected @@ -0,0 +1,3 @@ +Found 2 candidates: + func Map(v invalid type) (invalid type) + var Value int diff --git a/_testing/test.0081/out.expected.go1.26 b/_testing/test.0081/out.expected.go1.26 new file mode 100644 index 00000000..d1d87022 --- /dev/null +++ b/_testing/test.0081/out.expected.go1.26 @@ -0,0 +1,3 @@ +Found 2 candidates: + func Map(v invalid type) (invalid type) + var Value int diff --git a/_testing/test.0081/out.expected.go1.27 b/_testing/test.0081/out.expected.go1.27 new file mode 100644 index 00000000..e6615376 --- /dev/null +++ b/_testing/test.0081/out.expected.go1.27 @@ -0,0 +1,3 @@ +Found 2 candidates: + func Map(v U) U + var Value int diff --git a/_testing/test.0081/test.go.in b/_testing/test.0081/test.go.in new file mode 100644 index 00000000..35f471ba --- /dev/null +++ b/_testing/test.0081/test.go.in @@ -0,0 +1,9 @@ +package main + +type Box[T any] struct { Value T } +func (b Box[T]) Map[U any](v U) U { return v } + +func main() { + var box Box[int] + box. +} diff --git a/_testing/test.0082/cursor.204 b/_testing/test.0082/cursor.204 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0082/out.expected b/_testing/test.0082/out.expected new file mode 100644 index 00000000..ce21d4e2 --- /dev/null +++ b/_testing/test.0082/out.expected @@ -0,0 +1,3 @@ +Found 2 candidates: + func Convert(v invalid type) (invalid type) + var Value int diff --git a/_testing/test.0082/out.expected.go1.26 b/_testing/test.0082/out.expected.go1.26 new file mode 100644 index 00000000..ce21d4e2 --- /dev/null +++ b/_testing/test.0082/out.expected.go1.26 @@ -0,0 +1,3 @@ +Found 2 candidates: + func Convert(v invalid type) (invalid type) + var Value int diff --git a/_testing/test.0082/out.expected.go1.27 b/_testing/test.0082/out.expected.go1.27 new file mode 100644 index 00000000..75363209 --- /dev/null +++ b/_testing/test.0082/out.expected.go1.27 @@ -0,0 +1,3 @@ +Found 2 candidates: + func Convert(v U) Result[U] + var Value int diff --git a/_testing/test.0082/test.go.in b/_testing/test.0082/test.go.in new file mode 100644 index 00000000..e32f28c3 --- /dev/null +++ b/_testing/test.0082/test.go.in @@ -0,0 +1,10 @@ +package main + +type Box[T any] struct { Value T } +type Result[U any] struct { Output U } +func (b Box[T]) Convert[U any](v U) Result[U] { return Result[U]{Output: v} } + +func main() { + var box Box[int] + box. +} diff --git a/_testing/test.0083/cursor.196 b/_testing/test.0083/cursor.196 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0083/out.expected b/_testing/test.0083/out.expected new file mode 100644 index 00000000..bee994d4 --- /dev/null +++ b/_testing/test.0083/out.expected @@ -0,0 +1,4 @@ +Found 3 candidates: + func Swap(c invalid type, d invalid type) (invalid type) + var First int + var Second string diff --git a/_testing/test.0083/out.expected.go1.26 b/_testing/test.0083/out.expected.go1.26 new file mode 100644 index 00000000..bee994d4 --- /dev/null +++ b/_testing/test.0083/out.expected.go1.26 @@ -0,0 +1,4 @@ +Found 3 candidates: + func Swap(c invalid type, d invalid type) (invalid type) + var First int + var Second string diff --git a/_testing/test.0083/out.expected.go1.27 b/_testing/test.0083/out.expected.go1.27 new file mode 100644 index 00000000..9ec30f0d --- /dev/null +++ b/_testing/test.0083/out.expected.go1.27 @@ -0,0 +1,4 @@ +Found 3 candidates: + func Swap(c C, d D) (Pair[D, C]) + var First int + var Second string diff --git a/_testing/test.0083/test.go.in b/_testing/test.0083/test.go.in new file mode 100644 index 00000000..8432ff94 --- /dev/null +++ b/_testing/test.0083/test.go.in @@ -0,0 +1,9 @@ +package main + +type Pair[A, B any] struct { First A; Second B } +func (p Pair[A, B]) Swap[C, D any](c C, d D) Pair[D, C] { return Pair[D, C]{d, c} } + +func main() { + var pair Pair[int, string] + pair. +} From 1833c87b2233087ef163cae3bec69bf311ad361c Mon Sep 17 00:00:00 2001 From: visualfc Date: Sat, 29 Aug 2026 20:52:46 +0800 Subject: [PATCH 04/11] add version-specific autocomplete expectations --- .github/workflows/go.yml | 14 +++- _testing/run.rb | 6 +- _testing/test.0001/out.expected | 2 +- _testing/test.0001/out.expected.go1.26 | 42 ++++++++++ _testing/test.0001/out.expected.go1.27 | 42 ++++++++++ _testing/test.0011/out.expected | 6 +- _testing/test.0011/out.expected.go1.26 | 104 ++++++++++++++++++++++++ _testing/test.0011/out.expected.go1.27 | 106 +++++++++++++++++++++++++ _testing/test.0023/out.expected | 2 +- _testing/test.0023/out.expected.go1.26 | 42 ++++++++++ _testing/test.0023/out.expected.go1.27 | 42 ++++++++++ _testing/test.0029/out.expected | 2 +- _testing/test.0029/out.expected.go1.26 | 44 ++++++++++ _testing/test.0029/out.expected.go1.27 | 44 ++++++++++ _testing/test.0045/out.expected | 2 +- _testing/test.0045/out.expected.go1.26 | 42 ++++++++++ _testing/test.0045/out.expected.go1.27 | 42 ++++++++++ _testing/test.0046/out.expected | 2 +- _testing/test.0046/out.expected.go1.26 | 42 ++++++++++ _testing/test.0046/out.expected.go1.27 | 42 ++++++++++ 20 files changed, 658 insertions(+), 12 deletions(-) create mode 100644 _testing/test.0001/out.expected.go1.26 create mode 100644 _testing/test.0001/out.expected.go1.27 create mode 100644 _testing/test.0011/out.expected.go1.26 create mode 100644 _testing/test.0011/out.expected.go1.27 create mode 100644 _testing/test.0023/out.expected.go1.26 create mode 100644 _testing/test.0023/out.expected.go1.27 create mode 100644 _testing/test.0029/out.expected.go1.26 create mode 100644 _testing/test.0029/out.expected.go1.27 create mode 100644 _testing/test.0045/out.expected.go1.26 create mode 100644 _testing/test.0045/out.expected.go1.27 create mode 100644 _testing/test.0046/out.expected.go1.26 create mode 100644 _testing/test.0046/out.expected.go1.27 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 34fb2454..d36cda72 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -10,7 +10,7 @@ jobs: Test: strategy: matrix: - go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x] + go-version: [1.25.x, 1.26.x, 1.27.x] os: [ubuntu-latest, windows-latest, macos-11] runs-on: ${{ matrix.os }} steps: @@ -22,5 +22,15 @@ jobs: go-version: ${{ matrix.go-version }} - name: Build - run: go build -v + run: go build -v -o _testing/gocode + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + + - name: Autocomplete regression tests + working-directory: _testing + shell: bash + run: PATH="$GITHUB_WORKSPACE/_testing:$PATH" ruby run.rb diff --git a/_testing/run.rb b/_testing/run.rb index 5ee85c2e..81b5d522 100755 --- a/_testing/run.rb +++ b/_testing/run.rb @@ -35,7 +35,11 @@ def run_test(t) $stats.total += 1 cursorpos = Dir["#{t}/cursor.*"].map{|d| File.extname(d)[1..-1]}.first - outexpected = IO.read("#{t}/out.expected") rescue "To be determined" + version = `go env GOVERSION 2>/dev/null`.strip.sub(/^go/, '') + major_minor = version.split('.')[0, 2].join('.') + versioned = "#{t}/out.expected.go#{major_minor}" + expected_file = File.file?(versioned) ? versioned : "#{t}/out.expected" + outexpected = IO.read(expected_file) rescue "To be determined" filename = "#{t}/test.go.in" out = %x[gocode -in #{filename} autocomplete #{filename} #{cursorpos}] diff --git a/_testing/test.0001/out.expected b/_testing/test.0001/out.expected index 41c26ea4..55068de5 100644 --- a/_testing/test.0001/out.expected +++ b/_testing/test.0001/out.expected @@ -2,7 +2,7 @@ Found 41 candidates: func Append(b []byte, a ...interface{}) []byte func Appendf(b []byte, format string, a ...interface{}) []byte func Appendln(b []byte, a ...interface{}) []byte - func Errorf(format string, a ...interface{}) (err error) + func Errorf(format string, a ...interface{}) error func Flag(c int) bool func Format(f fmt.State, verb rune) func FormatString(state fmt.State, verb rune) string diff --git a/_testing/test.0001/out.expected.go1.26 b/_testing/test.0001/out.expected.go1.26 new file mode 100644 index 00000000..55068de5 --- /dev/null +++ b/_testing/test.0001/out.expected.go1.26 @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) error + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0001/out.expected.go1.27 b/_testing/test.0001/out.expected.go1.27 new file mode 100644 index 00000000..41c26ea4 --- /dev/null +++ b/_testing/test.0001/out.expected.go1.27 @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0011/out.expected b/_testing/test.0011/out.expected index 40c225e7..f4e24d72 100644 --- a/_testing/test.0011/out.expected +++ b/_testing/test.0011/out.expected @@ -1,4 +1,4 @@ -Found 105 candidates: +Found 103 candidates: func Addr() reflect.Value func Bool() bool func Bytes() []byte @@ -15,7 +15,7 @@ Found 105 candidates: func Cap() int func Clear() func Close() - func Comparable() (#rv1 bool) + func Comparable() bool func Complex() complex128 func Convert(t reflect.Type) reflect.Value func Elem() reflect.Value @@ -25,7 +25,6 @@ Found 105 candidates: func FieldByIndexErr(index []int) (reflect.Value, error) func FieldByName(name string) reflect.Value func FieldByNameFunc(match func(string) bool) reflect.Value - func Fields() (iter.Seq2[reflect.StructField, reflect.Value]) func Float() float64 func Grow(n int) func Index(i int) reflect.Value @@ -42,7 +41,6 @@ Found 105 candidates: func MapRange() *reflect.MapIter func Method(i int) reflect.Value func MethodByName(name string) reflect.Value - func Methods() (iter.Seq2[reflect.Method, reflect.Value]) func NumField() int func NumMethod() int func OverflowComplex(x complex128) bool diff --git a/_testing/test.0011/out.expected.go1.26 b/_testing/test.0011/out.expected.go1.26 new file mode 100644 index 00000000..f4e24d72 --- /dev/null +++ b/_testing/test.0011/out.expected.go1.26 @@ -0,0 +1,104 @@ +Found 103 candidates: + func Addr() reflect.Value + func Bool() bool + func Bytes() []byte + func Call(in []reflect.Value) []reflect.Value + func CallSlice(in []reflect.Value) []reflect.Value + func CanAddr() bool + func CanComplex() bool + func CanConvert(t reflect.Type) bool + func CanFloat() bool + func CanInt() bool + func CanInterface() bool + func CanSet() bool + func CanUint() bool + func Cap() int + func Clear() + func Close() + func Comparable() bool + func Complex() complex128 + func Convert(t reflect.Type) reflect.Value + func Elem() reflect.Value + func Equal(u reflect.Value) bool + func Field(i int) reflect.Value + func FieldByIndex(index []int) reflect.Value + func FieldByIndexErr(index []int) (reflect.Value, error) + func FieldByName(name string) reflect.Value + func FieldByNameFunc(match func(string) bool) reflect.Value + func Float() float64 + func Grow(n int) + func Index(i int) reflect.Value + func Int() int64 + func Interface() (i interface{}) + func InterfaceData() [2]uintptr + func IsNil() bool + func IsValid() bool + func IsZero() bool + func Kind() reflect.Kind + func Len() int + func MapIndex(key reflect.Value) reflect.Value + func MapKeys() []reflect.Value + func MapRange() *reflect.MapIter + func Method(i int) reflect.Value + func MethodByName(name string) reflect.Value + func NumField() int + func NumMethod() int + func OverflowComplex(x complex128) bool + func OverflowFloat(x float64) bool + func OverflowInt(x int64) bool + func OverflowUint(x uint64) bool + func Pointer() uintptr + func Recv() (x reflect.Value, ok bool) + func Send(x reflect.Value) + func Seq() iter.Seq[reflect.Value] + func Seq2() (iter.Seq2[reflect.Value, reflect.Value]) + func Set(x reflect.Value) + func SetBool(x bool) + func SetBytes(x []byte) + func SetCap(n int) + func SetComplex(x complex128) + func SetFloat(x float64) + func SetInt(x int64) + func SetIterKey(iter *reflect.MapIter) + func SetIterValue(iter *reflect.MapIter) + func SetLen(n int) + func SetMapIndex(key reflect.Value, elem reflect.Value) + func SetPointer(x unsafe.Pointer) + func SetString(x string) + func SetUint(x uint64) + func SetZero() + func Slice(i int, j int) reflect.Value + func Slice3(i int, j int, k int) reflect.Value + func String() string + func TryRecv() (x reflect.Value, ok bool) + func TrySend(x reflect.Value) bool + func Type() reflect.Type + func Uint() uint64 + func UnsafeAddr() uintptr + func UnsafePointer() unsafe.Pointer + func abiType() *abi.Type + func abiTypeSlow() *abi.Type + func assignTo(context string, dst *abi.Type, target unsafe.Pointer) reflect.Value + func bytesSlow() []byte + func call(op string, in []reflect.Value) []reflect.Value + func capNonSlice() int + func extendSlice(n int) reflect.Value + func grow(n int) + func kind() reflect.Kind + func lenNonSlice() int + func mustBe(expected reflect.Kind) + func mustBeAssignable() + func mustBeAssignableSlow() + func mustBeExported() + func mustBeExportedSlow() + func panicNotBool() + func panicNotMap() + func pointer() unsafe.Pointer + func recv(nb bool) (val reflect.Value, ok bool) + func ro() reflect.flag + func runes() []rune + func send(x reflect.Value, nb bool) (selected bool) + func setRunes(x []rune) + func stringNonString() string + func typ() *abi.Type + func typeSlow() reflect.Type diff --git a/_testing/test.0011/out.expected.go1.27 b/_testing/test.0011/out.expected.go1.27 new file mode 100644 index 00000000..40c225e7 --- /dev/null +++ b/_testing/test.0011/out.expected.go1.27 @@ -0,0 +1,106 @@ +Found 105 candidates: + func Addr() reflect.Value + func Bool() bool + func Bytes() []byte + func Call(in []reflect.Value) []reflect.Value + func CallSlice(in []reflect.Value) []reflect.Value + func CanAddr() bool + func CanComplex() bool + func CanConvert(t reflect.Type) bool + func CanFloat() bool + func CanInt() bool + func CanInterface() bool + func CanSet() bool + func CanUint() bool + func Cap() int + func Clear() + func Close() + func Comparable() (#rv1 bool) + func Complex() complex128 + func Convert(t reflect.Type) reflect.Value + func Elem() reflect.Value + func Equal(u reflect.Value) bool + func Field(i int) reflect.Value + func FieldByIndex(index []int) reflect.Value + func FieldByIndexErr(index []int) (reflect.Value, error) + func FieldByName(name string) reflect.Value + func FieldByNameFunc(match func(string) bool) reflect.Value + func Fields() (iter.Seq2[reflect.StructField, reflect.Value]) + func Float() float64 + func Grow(n int) + func Index(i int) reflect.Value + func Int() int64 + func Interface() (i interface{}) + func InterfaceData() [2]uintptr + func IsNil() bool + func IsValid() bool + func IsZero() bool + func Kind() reflect.Kind + func Len() int + func MapIndex(key reflect.Value) reflect.Value + func MapKeys() []reflect.Value + func MapRange() *reflect.MapIter + func Method(i int) reflect.Value + func MethodByName(name string) reflect.Value + func Methods() (iter.Seq2[reflect.Method, reflect.Value]) + func NumField() int + func NumMethod() int + func OverflowComplex(x complex128) bool + func OverflowFloat(x float64) bool + func OverflowInt(x int64) bool + func OverflowUint(x uint64) bool + func Pointer() uintptr + func Recv() (x reflect.Value, ok bool) + func Send(x reflect.Value) + func Seq() iter.Seq[reflect.Value] + func Seq2() (iter.Seq2[reflect.Value, reflect.Value]) + func Set(x reflect.Value) + func SetBool(x bool) + func SetBytes(x []byte) + func SetCap(n int) + func SetComplex(x complex128) + func SetFloat(x float64) + func SetInt(x int64) + func SetIterKey(iter *reflect.MapIter) + func SetIterValue(iter *reflect.MapIter) + func SetLen(n int) + func SetMapIndex(key reflect.Value, elem reflect.Value) + func SetPointer(x unsafe.Pointer) + func SetString(x string) + func SetUint(x uint64) + func SetZero() + func Slice(i int, j int) reflect.Value + func Slice3(i int, j int, k int) reflect.Value + func String() string + func TryRecv() (x reflect.Value, ok bool) + func TrySend(x reflect.Value) bool + func Type() reflect.Type + func Uint() uint64 + func UnsafeAddr() uintptr + func UnsafePointer() unsafe.Pointer + func abiType() *abi.Type + func abiTypeSlow() *abi.Type + func assignTo(context string, dst *abi.Type, target unsafe.Pointer) reflect.Value + func bytesSlow() []byte + func call(op string, in []reflect.Value) []reflect.Value + func capNonSlice() int + func extendSlice(n int) reflect.Value + func grow(n int) + func kind() reflect.Kind + func lenNonSlice() int + func mustBe(expected reflect.Kind) + func mustBeAssignable() + func mustBeAssignableSlow() + func mustBeExported() + func mustBeExportedSlow() + func panicNotBool() + func panicNotMap() + func pointer() unsafe.Pointer + func recv(nb bool) (val reflect.Value, ok bool) + func ro() reflect.flag + func runes() []rune + func send(x reflect.Value, nb bool) (selected bool) + func setRunes(x []rune) + func stringNonString() string + func typ() *abi.Type + func typeSlow() reflect.Type diff --git a/_testing/test.0023/out.expected b/_testing/test.0023/out.expected index 41c26ea4..55068de5 100644 --- a/_testing/test.0023/out.expected +++ b/_testing/test.0023/out.expected @@ -2,7 +2,7 @@ Found 41 candidates: func Append(b []byte, a ...interface{}) []byte func Appendf(b []byte, format string, a ...interface{}) []byte func Appendln(b []byte, a ...interface{}) []byte - func Errorf(format string, a ...interface{}) (err error) + func Errorf(format string, a ...interface{}) error func Flag(c int) bool func Format(f fmt.State, verb rune) func FormatString(state fmt.State, verb rune) string diff --git a/_testing/test.0023/out.expected.go1.26 b/_testing/test.0023/out.expected.go1.26 new file mode 100644 index 00000000..55068de5 --- /dev/null +++ b/_testing/test.0023/out.expected.go1.26 @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) error + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0023/out.expected.go1.27 b/_testing/test.0023/out.expected.go1.27 new file mode 100644 index 00000000..41c26ea4 --- /dev/null +++ b/_testing/test.0023/out.expected.go1.27 @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0029/out.expected b/_testing/test.0029/out.expected index d3293862..12a41baf 100644 --- a/_testing/test.0029/out.expected +++ b/_testing/test.0029/out.expected @@ -2,7 +2,7 @@ Found 43 candidates: func Append(b []byte, a ...interface{}) []byte func Appendf(b []byte, format string, a ...interface{}) []byte func Appendln(b []byte, a ...interface{}) []byte - func Errorf(format string, a ...interface{}) (err error) + func Errorf(format string, a ...interface{}) error func Flag(c int) bool func Format(f fmt.State, verb rune) func FormatString(state fmt.State, verb rune) string diff --git a/_testing/test.0029/out.expected.go1.26 b/_testing/test.0029/out.expected.go1.26 new file mode 100644 index 00000000..12a41baf --- /dev/null +++ b/_testing/test.0029/out.expected.go1.26 @@ -0,0 +1,44 @@ +Found 43 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) error + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + func main() + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface + var a Formatter diff --git a/_testing/test.0029/out.expected.go1.27 b/_testing/test.0029/out.expected.go1.27 new file mode 100644 index 00000000..d3293862 --- /dev/null +++ b/_testing/test.0029/out.expected.go1.27 @@ -0,0 +1,44 @@ +Found 43 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + func main() + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface + var a Formatter diff --git a/_testing/test.0045/out.expected b/_testing/test.0045/out.expected index 41c26ea4..55068de5 100644 --- a/_testing/test.0045/out.expected +++ b/_testing/test.0045/out.expected @@ -2,7 +2,7 @@ Found 41 candidates: func Append(b []byte, a ...interface{}) []byte func Appendf(b []byte, format string, a ...interface{}) []byte func Appendln(b []byte, a ...interface{}) []byte - func Errorf(format string, a ...interface{}) (err error) + func Errorf(format string, a ...interface{}) error func Flag(c int) bool func Format(f fmt.State, verb rune) func FormatString(state fmt.State, verb rune) string diff --git a/_testing/test.0045/out.expected.go1.26 b/_testing/test.0045/out.expected.go1.26 new file mode 100644 index 00000000..55068de5 --- /dev/null +++ b/_testing/test.0045/out.expected.go1.26 @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) error + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0045/out.expected.go1.27 b/_testing/test.0045/out.expected.go1.27 new file mode 100644 index 00000000..41c26ea4 --- /dev/null +++ b/_testing/test.0045/out.expected.go1.27 @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0046/out.expected b/_testing/test.0046/out.expected index 41c26ea4..55068de5 100644 --- a/_testing/test.0046/out.expected +++ b/_testing/test.0046/out.expected @@ -2,7 +2,7 @@ Found 41 candidates: func Append(b []byte, a ...interface{}) []byte func Appendf(b []byte, format string, a ...interface{}) []byte func Appendln(b []byte, a ...interface{}) []byte - func Errorf(format string, a ...interface{}) (err error) + func Errorf(format string, a ...interface{}) error func Flag(c int) bool func Format(f fmt.State, verb rune) func FormatString(state fmt.State, verb rune) string diff --git a/_testing/test.0046/out.expected.go1.26 b/_testing/test.0046/out.expected.go1.26 new file mode 100644 index 00000000..55068de5 --- /dev/null +++ b/_testing/test.0046/out.expected.go1.26 @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) error + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0046/out.expected.go1.27 b/_testing/test.0046/out.expected.go1.27 new file mode 100644 index 00000000..41c26ea4 --- /dev/null +++ b/_testing/test.0046/out.expected.go1.27 @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface From a8aaa0e4d1349519dc071cd9473b4215722cfcb2 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sat, 29 Aug 2026 21:09:21 +0800 Subject: [PATCH 05/11] add unsafe autocomplete tests --- _testing/DESC | 5 +++++ _testing/test.0084/cursor.53 | 0 _testing/test.0084/out.expected | 10 ++++++++++ _testing/test.0084/test.go.in | 7 +++++++ _testing/test.0085/cursor.74 | 0 _testing/test.0085/out.expected | 1 + _testing/test.0085/test.go.in | 8 ++++++++ _testing/test.0086/cursor.86 | 0 _testing/test.0086/out.expected | 1 + _testing/test.0086/test.go.in | 8 ++++++++ _testing/test.0087/cursor.87 | 0 _testing/test.0087/out.expected | 1 + _testing/test.0087/test.go.in | 8 ++++++++ _testing/test.0088/cursor.90 | 0 _testing/test.0088/out.expected | 1 + _testing/test.0088/test.go.in | 10 ++++++++++ 16 files changed, 60 insertions(+) create mode 100644 _testing/test.0084/cursor.53 create mode 100644 _testing/test.0084/out.expected create mode 100644 _testing/test.0084/test.go.in create mode 100644 _testing/test.0085/cursor.74 create mode 100644 _testing/test.0085/out.expected create mode 100644 _testing/test.0085/test.go.in create mode 100644 _testing/test.0086/cursor.86 create mode 100644 _testing/test.0086/out.expected create mode 100644 _testing/test.0086/test.go.in create mode 100644 _testing/test.0087/cursor.87 create mode 100644 _testing/test.0087/out.expected create mode 100644 _testing/test.0087/test.go.in create mode 100644 _testing/test.0088/cursor.90 create mode 100644 _testing/test.0088/out.expected create mode 100644 _testing/test.0088/test.go.in diff --git a/_testing/DESC b/_testing/DESC index 229f1d78..4f584389 100644 --- a/_testing/DESC +++ b/_testing/DESC @@ -81,3 +81,8 @@ test.0080 - constrained generic method test.0081 - Go 1.27 generic method type parameter test.0082 - generic method returning instantiated generic type test.0083 - generic method with multiple own type parameters +test.0084 - unsafe package declarations +test.0085 - unsafe.Pointer type +test.0086 - unsafe.SliceData result +test.0087 - unsafe.StringData result +test.0088 - unsafe.Pointer type alias diff --git a/_testing/test.0084/cursor.53 b/_testing/test.0084/cursor.53 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0084/out.expected b/_testing/test.0084/out.expected new file mode 100644 index 00000000..5e0f26c2 --- /dev/null +++ b/_testing/test.0084/out.expected @@ -0,0 +1,10 @@ +Found 9 candidates: + func Add(ptr Pointer, len IntegerType) Pointer + func Alignof(x ArbitraryType) uintptr + func Offsetof(x ArbitraryType) uintptr + func Sizeof(x ArbitraryType) uintptr + func Slice(ptr *ArbitraryType, len IntegerType) []ArbitraryType + func SliceData(slice []ArbitraryType) *ArbitraryType + func String(ptr *byte, len IntegerType) string + func StringData(str string) *byte + type Pointer *ArbitraryType diff --git a/_testing/test.0084/test.go.in b/_testing/test.0084/test.go.in new file mode 100644 index 00000000..bc751c66 --- /dev/null +++ b/_testing/test.0084/test.go.in @@ -0,0 +1,7 @@ +package main + +import "unsafe" + +func main() { + unsafe. +} diff --git a/_testing/test.0085/cursor.74 b/_testing/test.0085/cursor.74 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0085/out.expected b/_testing/test.0085/out.expected new file mode 100644 index 00000000..25a78e98 --- /dev/null +++ b/_testing/test.0085/out.expected @@ -0,0 +1 @@ +Nothing to complete. diff --git a/_testing/test.0085/test.go.in b/_testing/test.0085/test.go.in new file mode 100644 index 00000000..a8d5f940 --- /dev/null +++ b/_testing/test.0085/test.go.in @@ -0,0 +1,8 @@ +package main + +import "unsafe" + +func main() { + var ptr unsafe.Pointer + ptr. +} diff --git a/_testing/test.0086/cursor.86 b/_testing/test.0086/cursor.86 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0086/out.expected b/_testing/test.0086/out.expected new file mode 100644 index 00000000..25a78e98 --- /dev/null +++ b/_testing/test.0086/out.expected @@ -0,0 +1 @@ +Nothing to complete. diff --git a/_testing/test.0086/test.go.in b/_testing/test.0086/test.go.in new file mode 100644 index 00000000..d770598f --- /dev/null +++ b/_testing/test.0086/test.go.in @@ -0,0 +1,8 @@ +package main + +import "unsafe" + +func main() { + var data []byte + unsafe.SliceData(data). +} diff --git a/_testing/test.0087/cursor.87 b/_testing/test.0087/cursor.87 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0087/out.expected b/_testing/test.0087/out.expected new file mode 100644 index 00000000..25a78e98 --- /dev/null +++ b/_testing/test.0087/out.expected @@ -0,0 +1 @@ +Nothing to complete. diff --git a/_testing/test.0087/test.go.in b/_testing/test.0087/test.go.in new file mode 100644 index 00000000..63b7c9af --- /dev/null +++ b/_testing/test.0087/test.go.in @@ -0,0 +1,8 @@ +package main + +import "unsafe" + +func main() { + var text string + unsafe.StringData(text). +} diff --git a/_testing/test.0088/cursor.90 b/_testing/test.0088/cursor.90 new file mode 100644 index 00000000..e69de29b diff --git a/_testing/test.0088/out.expected b/_testing/test.0088/out.expected new file mode 100644 index 00000000..25a78e98 --- /dev/null +++ b/_testing/test.0088/out.expected @@ -0,0 +1 @@ +Nothing to complete. diff --git a/_testing/test.0088/test.go.in b/_testing/test.0088/test.go.in new file mode 100644 index 00000000..d6a469a4 --- /dev/null +++ b/_testing/test.0088/test.go.in @@ -0,0 +1,10 @@ +package main + +import "unsafe" + +type Raw = unsafe.Pointer + +func main() { + var raw Raw + raw. +} From 4f35ad3ebc62de4fec49bb4dccbe357017cc84b1 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sat, 29 Aug 2026 21:09:36 +0800 Subject: [PATCH 06/11] add server types_info tests --- _testing/DESC | 8 +++++ _testing/README | 4 +++ _testing/typesinfo.0001/cursor.127 | 1 + _testing/typesinfo.0001/out.expected | 2 ++ _testing/typesinfo.0001/test.go.in | 10 ++++++ _testing/typesinfo.0002/cursor.33 | 1 + _testing/typesinfo.0002/out.expected | 2 ++ _testing/typesinfo.0002/test.go.in | 6 ++++ _testing/typesinfo.0003/cursor.52 | 1 + _testing/typesinfo.0003/out.expected | 5 +++ _testing/typesinfo.0003/test.go.in | 7 ++++ _testing/typesinfo.0004/cursor.24 | 1 + _testing/typesinfo.0004/out.expected | 2 ++ _testing/typesinfo.0004/test.go.in | 11 ++++++ _testing/typesinfo.0005/cursor.144 | 1 + _testing/typesinfo.0005/out.expected | 2 ++ _testing/typesinfo.0005/test.go.in | 11 ++++++ _testing/typesinfo.0006/cursor.185 | 1 + _testing/typesinfo.0006/out.expected | 2 ++ _testing/typesinfo.0006/test.go.in | 11 ++++++ _testing/typesinfo.0007/cursor.201 | 1 + _testing/typesinfo.0007/out.expected | 2 ++ _testing/typesinfo.0007/test.go.in | 11 ++++++ _testing/typesinfo.0008/cursor.209 | 1 + _testing/typesinfo.0008/out.expected | 2 ++ _testing/typesinfo.0008/test.go.in | 12 +++++++ _testing/typesinfo.rb | 51 ++++++++++++++++++++++++++++ 27 files changed, 169 insertions(+) create mode 100644 _testing/typesinfo.0001/cursor.127 create mode 100644 _testing/typesinfo.0001/out.expected create mode 100644 _testing/typesinfo.0001/test.go.in create mode 100644 _testing/typesinfo.0002/cursor.33 create mode 100644 _testing/typesinfo.0002/out.expected create mode 100644 _testing/typesinfo.0002/test.go.in create mode 100644 _testing/typesinfo.0003/cursor.52 create mode 100644 _testing/typesinfo.0003/out.expected create mode 100644 _testing/typesinfo.0003/test.go.in create mode 100644 _testing/typesinfo.0004/cursor.24 create mode 100644 _testing/typesinfo.0004/out.expected create mode 100644 _testing/typesinfo.0004/test.go.in create mode 100644 _testing/typesinfo.0005/cursor.144 create mode 100644 _testing/typesinfo.0005/out.expected create mode 100644 _testing/typesinfo.0005/test.go.in create mode 100644 _testing/typesinfo.0006/cursor.185 create mode 100644 _testing/typesinfo.0006/out.expected create mode 100644 _testing/typesinfo.0006/test.go.in create mode 100644 _testing/typesinfo.0007/cursor.201 create mode 100644 _testing/typesinfo.0007/out.expected create mode 100644 _testing/typesinfo.0007/test.go.in create mode 100644 _testing/typesinfo.0008/cursor.209 create mode 100644 _testing/typesinfo.0008/out.expected create mode 100644 _testing/typesinfo.0008/test.go.in create mode 100644 _testing/typesinfo.rb diff --git a/_testing/DESC b/_testing/DESC index 4f584389..4866069f 100644 --- a/_testing/DESC +++ b/_testing/DESC @@ -86,3 +86,11 @@ test.0085 - unsafe.Pointer type test.0086 - unsafe.SliceData result test.0087 - unsafe.StringData result test.0088 - unsafe.Pointer type alias +typesinfo.0001 - instantiated generic method +typesinfo.0002 - local variable +typesinfo.0003 - standard library function and documentation +typesinfo.0004 - generic type parameter +typesinfo.0005 - instantiated generic composite literal field +typesinfo.0006 - generic function instantiation +typesinfo.0007 - instantiated generic selector field +typesinfo.0008 - interface method selector diff --git a/_testing/README b/_testing/README index 1e876dd6..ede2eb09 100644 --- a/_testing/README +++ b/_testing/README @@ -8,3 +8,7 @@ because usually you spend some time in editor between requests and that time is wasted on a GC run, but testing app throws requests one after another and it causes GC to eat a lot of CPU. So.. don't worry about that. + +Server-side type information tests can be run with: + + ruby typesinfo.rb diff --git a/_testing/typesinfo.0001/cursor.127 b/_testing/typesinfo.0001/cursor.127 new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/_testing/typesinfo.0001/cursor.127 @@ -0,0 +1 @@ + diff --git a/_testing/typesinfo.0001/out.expected b/_testing/typesinfo.0001/out.expected new file mode 100644 index 00000000..c2d57502 --- /dev/null +++ b/_testing/typesinfo.0001/out.expected @@ -0,0 +1,2 @@ +FILE:5:17 +func (Box[int]).Get() int diff --git a/_testing/typesinfo.0001/test.go.in b/_testing/typesinfo.0001/test.go.in new file mode 100644 index 00000000..f721516b --- /dev/null +++ b/_testing/typesinfo.0001/test.go.in @@ -0,0 +1,10 @@ +package main + +type Box[T any] struct { Value T } + +func (b Box[T]) Get() T { return b.Value } + +func main() { + var b Box[int] + b.Get() +} diff --git a/_testing/typesinfo.0002/cursor.33 b/_testing/typesinfo.0002/cursor.33 new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/_testing/typesinfo.0002/cursor.33 @@ -0,0 +1 @@ + diff --git a/_testing/typesinfo.0002/out.expected b/_testing/typesinfo.0002/out.expected new file mode 100644 index 00000000..ab194117 --- /dev/null +++ b/_testing/typesinfo.0002/out.expected @@ -0,0 +1,2 @@ +FILE:4:6 +var value int diff --git a/_testing/typesinfo.0002/test.go.in b/_testing/typesinfo.0002/test.go.in new file mode 100644 index 00000000..63b1a976 --- /dev/null +++ b/_testing/typesinfo.0002/test.go.in @@ -0,0 +1,6 @@ +package main + +func main() { + var value int + value++ +} diff --git a/_testing/typesinfo.0003/cursor.52 b/_testing/typesinfo.0003/cursor.52 new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/_testing/typesinfo.0003/cursor.52 @@ -0,0 +1 @@ + diff --git a/_testing/typesinfo.0003/out.expected b/_testing/typesinfo.0003/out.expected new file mode 100644 index 00000000..fa447f0e --- /dev/null +++ b/_testing/typesinfo.0003/out.expected @@ -0,0 +1,5 @@ +GOROOT/src/fmt/print.go:LINE:COLUMN +func fmt.Println(a ...any) (n int, err error) +Println formats using the default formats for its operands and writes to standard output. +Spaces are always added between operands and a newline is appended. +It returns the number of bytes written and any write error encountered. diff --git a/_testing/typesinfo.0003/test.go.in b/_testing/typesinfo.0003/test.go.in new file mode 100644 index 00000000..d8fa9292 --- /dev/null +++ b/_testing/typesinfo.0003/test.go.in @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("hello") +} diff --git a/_testing/typesinfo.0004/cursor.24 b/_testing/typesinfo.0004/cursor.24 new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/_testing/typesinfo.0004/cursor.24 @@ -0,0 +1 @@ + diff --git a/_testing/typesinfo.0004/out.expected b/_testing/typesinfo.0004/out.expected new file mode 100644 index 00000000..0fd667c0 --- /dev/null +++ b/_testing/typesinfo.0004/out.expected @@ -0,0 +1,2 @@ +FILE:3:11 +type parameter A any diff --git a/_testing/typesinfo.0004/test.go.in b/_testing/typesinfo.0004/test.go.in new file mode 100644 index 00000000..24be82c8 --- /dev/null +++ b/_testing/typesinfo.0004/test.go.in @@ -0,0 +1,11 @@ +package main + +type Pair[A, B any] struct { First A; Second B } + +func Identity[T any](v T) T { return v } + +func main() { + p := Pair[string, int]{First: "x", Second: 1} + _ = p.First + _ = Identity[int](p.Second) +} diff --git a/_testing/typesinfo.0005/cursor.144 b/_testing/typesinfo.0005/cursor.144 new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/_testing/typesinfo.0005/cursor.144 @@ -0,0 +1 @@ + diff --git a/_testing/typesinfo.0005/out.expected b/_testing/typesinfo.0005/out.expected new file mode 100644 index 00000000..0035a525 --- /dev/null +++ b/_testing/typesinfo.0005/out.expected @@ -0,0 +1,2 @@ +FILE:3:30 +field First string diff --git a/_testing/typesinfo.0005/test.go.in b/_testing/typesinfo.0005/test.go.in new file mode 100644 index 00000000..24be82c8 --- /dev/null +++ b/_testing/typesinfo.0005/test.go.in @@ -0,0 +1,11 @@ +package main + +type Pair[A, B any] struct { First A; Second B } + +func Identity[T any](v T) T { return v } + +func main() { + p := Pair[string, int]{First: "x", Second: 1} + _ = p.First + _ = Identity[int](p.Second) +} diff --git a/_testing/typesinfo.0006/cursor.185 b/_testing/typesinfo.0006/cursor.185 new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/_testing/typesinfo.0006/cursor.185 @@ -0,0 +1 @@ + diff --git a/_testing/typesinfo.0006/out.expected b/_testing/typesinfo.0006/out.expected new file mode 100644 index 00000000..1a7f5e5d --- /dev/null +++ b/_testing/typesinfo.0006/out.expected @@ -0,0 +1,2 @@ +FILE:5:6 +func Identity[T any](v T) T diff --git a/_testing/typesinfo.0006/test.go.in b/_testing/typesinfo.0006/test.go.in new file mode 100644 index 00000000..24be82c8 --- /dev/null +++ b/_testing/typesinfo.0006/test.go.in @@ -0,0 +1,11 @@ +package main + +type Pair[A, B any] struct { First A; Second B } + +func Identity[T any](v T) T { return v } + +func main() { + p := Pair[string, int]{First: "x", Second: 1} + _ = p.First + _ = Identity[int](p.Second) +} diff --git a/_testing/typesinfo.0007/cursor.201 b/_testing/typesinfo.0007/cursor.201 new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/_testing/typesinfo.0007/cursor.201 @@ -0,0 +1 @@ + diff --git a/_testing/typesinfo.0007/out.expected b/_testing/typesinfo.0007/out.expected new file mode 100644 index 00000000..e94dc68d --- /dev/null +++ b/_testing/typesinfo.0007/out.expected @@ -0,0 +1,2 @@ +FILE:3:39 +field Second int diff --git a/_testing/typesinfo.0007/test.go.in b/_testing/typesinfo.0007/test.go.in new file mode 100644 index 00000000..24be82c8 --- /dev/null +++ b/_testing/typesinfo.0007/test.go.in @@ -0,0 +1,11 @@ +package main + +type Pair[A, B any] struct { First A; Second B } + +func Identity[T any](v T) T { return v } + +func main() { + p := Pair[string, int]{First: "x", Second: 1} + _ = p.First + _ = Identity[int](p.Second) +} diff --git a/_testing/typesinfo.0008/cursor.209 b/_testing/typesinfo.0008/cursor.209 new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/_testing/typesinfo.0008/cursor.209 @@ -0,0 +1 @@ + diff --git a/_testing/typesinfo.0008/out.expected b/_testing/typesinfo.0008/out.expected new file mode 100644 index 00000000..0d754049 --- /dev/null +++ b/_testing/typesinfo.0008/out.expected @@ -0,0 +1,2 @@ +FILE:3:25 +func (Reader).Read([]byte) (int, error) diff --git a/_testing/typesinfo.0008/test.go.in b/_testing/typesinfo.0008/test.go.in new file mode 100644 index 00000000..f2189fd7 --- /dev/null +++ b/_testing/typesinfo.0008/test.go.in @@ -0,0 +1,12 @@ +package main + +type Reader interface { Read([]byte) (int, error) } + +type ByteReader struct{} + +func (ByteReader) Read(b []byte) (int, error) { return len(b), nil } + +func main() { + var r Reader = ByteReader{} + r.Read(nil) +} diff --git a/_testing/typesinfo.rb b/_testing/typesinfo.rb new file mode 100644 index 00000000..8f7eef14 --- /dev/null +++ b/_testing/typesinfo.rb @@ -0,0 +1,51 @@ +#!/usr/bin/env ruby +# encoding: utf-8 + +RED = "\033[0;31m" +GRN = "\033[0;32m" +NC = "\033[0m" + +root = File.expand_path(__dir__) +port = 40000 + (Process.pid % 1000) +addr = "127.0.0.1:#{port}" +server = Process.spawn("gocode", "-s", "-sock", "tcp", "-addr", addr, + chdir: root, out: File::NULL, err: File::NULL) +at_exit do + Process.kill("TERM", server) rescue nil + Process.wait(server) rescue nil +end + +require "socket" +100.times do + begin + TCPSocket.new("127.0.0.1", port).close + break + rescue Errno::ECONNREFUSED + sleep 0.01 + end +end + +tests = ARGV.empty? ? Dir["#{root}/typesinfo.*"].sort : ARGV.map { |t| File.expand_path(t, root) } +total = ok = 0 +tests.each do |dir| + next unless File.directory?(dir) + total += 1 + file = File.join(dir, "test.go.in") + cursor = Dir[File.join(dir, "cursor.*")].first.split(".").last + expected = File.read(File.join(dir, "out.expected")) + out = `gocode -sock tcp -addr #{addr} -in #{file} liteide_typesinfo #{file} #{cursor}` + out = out.gsub(File.expand_path(file), "FILE") + out = out.gsub(%r{/.*/go\d+\.\d+/src/}, "GOROOT/src/") + out = out.gsub(%r{GOROOT/src/([^:]+):\d+:\d+}, 'GOROOT/src/\\1:LINE:COLUMN') + if out == expected + puts "#{File.basename(dir)}: #{GRN}PASS!#{NC}" + ok += 1 + else + puts "#{File.basename(dir)}: #{RED}FAIL!#{NC}" + puts "Got:\n#{out}Expected:\n#{expected}" + end +end +puts "\nSummary (total: #{total})" +puts "#{GRN} PASS#{NC}: #{ok}" +puts "#{RED} FAIL#{NC}: #{total - ok}" +exit(total == ok ? 0 : 1) From dd87ec3aa9f0dff34de18f3b8ad1f18ad1d257e4 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sun, 30 Aug 2026 09:07:04 +0800 Subject: [PATCH 07/11] consolidate cross-platform regression tests --- .gitattributes | 1 + .github/workflows/go.yml | 12 +- _testing/README | 6 +- _testing/run.go | 178 ++++++++++++++++++ _testing/run.rb | 14 +- _testing/run_test.go | 34 ++++ _testing/test.0001/out.expected.go1.26 | 2 +- .../test.0001/out.expected.go1.26.windows | 42 +++++ .../test.0001/out.expected.go1.27.windows | 42 +++++ .../test.0007/out.expected.go1.25.windows | 10 + .../test.0007/out.expected.go1.26.windows | 10 + .../test.0007/out.expected.go1.27.windows | 10 + _testing/test.0011/out.expected.go1.26 | 6 +- .../test.0011/out.expected.go1.26.windows | 124 ++++++++++++ .../test.0011/out.expected.go1.27.windows | 124 ++++++++++++ _testing/test.0023/out.expected.go1.26 | 2 +- .../test.0023/out.expected.go1.26.windows | 42 +++++ .../test.0023/out.expected.go1.27.windows | 42 +++++ _testing/test.0029/out.expected.go1.26 | 2 +- .../test.0029/out.expected.go1.26.windows | 61 ++++++ .../test.0029/out.expected.go1.27.windows | 61 ++++++ _testing/test.0045/out.expected.go1.26 | 2 +- .../test.0045/out.expected.go1.26.windows | 42 +++++ .../test.0045/out.expected.go1.27.windows | 42 +++++ _testing/test.0046/out.expected.go1.26 | 2 +- .../test.0046/out.expected.go1.26.windows | 84 +++++++++ .../test.0046/out.expected.go1.27.windows | 84 +++++++++ .../test.0081/out.expected.go1.27.windows | 3 + .../test.0082/out.expected.go1.27.windows | 3 + .../test.0083/out.expected.go1.27.windows | 4 + _testing/typesinfo.rb | 35 +++- go.mod | 2 +- go.sum | 2 + 33 files changed, 1102 insertions(+), 28 deletions(-) create mode 100644 .gitattributes create mode 100644 _testing/run.go create mode 100644 _testing/run_test.go create mode 100644 _testing/test.0001/out.expected.go1.26.windows create mode 100644 _testing/test.0001/out.expected.go1.27.windows create mode 100644 _testing/test.0007/out.expected.go1.25.windows create mode 100644 _testing/test.0007/out.expected.go1.26.windows create mode 100644 _testing/test.0007/out.expected.go1.27.windows create mode 100644 _testing/test.0011/out.expected.go1.26.windows create mode 100644 _testing/test.0011/out.expected.go1.27.windows create mode 100644 _testing/test.0023/out.expected.go1.26.windows create mode 100644 _testing/test.0023/out.expected.go1.27.windows create mode 100644 _testing/test.0029/out.expected.go1.26.windows create mode 100644 _testing/test.0029/out.expected.go1.27.windows create mode 100644 _testing/test.0045/out.expected.go1.26.windows create mode 100644 _testing/test.0045/out.expected.go1.27.windows create mode 100644 _testing/test.0046/out.expected.go1.26.windows create mode 100644 _testing/test.0046/out.expected.go1.27.windows create mode 100644 _testing/test.0081/out.expected.go1.27.windows create mode 100644 _testing/test.0082/out.expected.go1.27.windows create mode 100644 _testing/test.0083/out.expected.go1.27.windows diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..6313b56c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d36cda72..469a087d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: go-version: [1.25.x, 1.26.x, 1.27.x] - os: [ubuntu-latest, windows-latest, macos-11] + os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -24,13 +24,7 @@ jobs: - name: Build run: go build -v -o _testing/gocode - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.3' - - - name: Autocomplete regression tests + - name: Regression tests working-directory: _testing - shell: bash - run: PATH="$GITHUB_WORKSPACE/_testing:$PATH" ruby run.rb + run: go test -v diff --git a/_testing/README b/_testing/README index ede2eb09..08627a4d 100644 --- a/_testing/README +++ b/_testing/README @@ -11,4 +11,8 @@ about that. Server-side type information tests can be run with: - ruby typesinfo.rb + go test -v -run TestTypesInfo + +Autocomplete regression tests can be run with: + + go test -v -run TestAutocomplete diff --git a/_testing/run.go b/_testing/run.go new file mode 100644 index 00000000..151abb97 --- /dev/null +++ b/_testing/run.go @@ -0,0 +1,178 @@ +package main + +import ( + "bytes" + "flag" + "fmt" + "io" + "os" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "sort" + "strconv" + "strings" + "time" +) + +func main() { + mode := flag.String("mode", "autocomplete", "test mode: autocomplete or typesinfo") + flag.Parse() + root, _ := os.Getwd() + bin := filepath.Join(root, "gocode") + if runtime.GOOS == "windows" { + if _, err := os.Stat(bin + ".exe"); err == nil { + bin += ".exe" + } + } + if _, err := os.Stat(bin); err != nil { + fail("gocode binary not found: %v", err) + } + var ok bool + if *mode == "typesinfo" { + ok = runTypesInfo(root, bin) + } else { + ok = runAutocomplete(root, bin) + } + if !ok { + os.Exit(1) + } +} + +func runAutocomplete(root, bin string) bool { + tests, _ := filepath.Glob(filepath.Join(root, "test.*")) + sort.Strings(tests) + version := goVersion() + platform := "" + if runtime.GOOS == "windows" { + platform = ".windows" + } + addr := fmt.Sprintf("127.0.0.1:%d", 41000+os.Getpid()%1000) + server := exec.Command(bin, "-s", "-sock", "tcp", "-addr", addr) + server.Stdout = io.Discard + server.Stderr = io.Discard + if err := server.Start(); err != nil { + fmt.Fprintf(os.Stderr, "start server: %v\n", err) + return false + } + defer func() { + exec.Command(bin, "-sock", "tcp", "-addr", addr, "close").Run() + server.Process.Kill() + server.Wait() + }() + time.Sleep(300 * time.Millisecond) + pass := 0 + for _, dir := range tests { + cursor := cursorOf(dir) + expected := expectedPath(dir, version, platform) + file := filepath.Join(dir, "test.go.in") + got, _ := command(bin, "-sock", "tcp", "-addr", addr, "-in", file, "autocomplete", file, strconv.Itoa(cursor)) + want, _ := os.ReadFile(expected) + if string(got) != string(want) { + fmt.Printf("%s: FAIL!\nGot:\n%sExpected:\n%s", filepath.Base(dir), got, want) + } else { + fmt.Printf("%s: PASS!\n", filepath.Base(dir)) + pass++ + } + } + fmt.Printf("\nSummary (total: %d)\n PASS: %d\n FAIL: %d\n", len(tests), pass, len(tests)-pass) + return pass == len(tests) +} + +func runTypesInfo(root, bin string) bool { + addr := fmt.Sprintf("127.0.0.1:%d", 40000+os.Getpid()%1000) + server := exec.Command(bin, "-s", "-sock", "tcp", "-addr", addr) + server.Stdout = io.Discard + server.Stderr = io.Discard + if err := server.Start(); err != nil { + fmt.Fprintf(os.Stderr, "start server: %v\n", err) + return false + } + defer func() { + exec.Command(bin, "-sock", "tcp", "-addr", addr, "close").Run() + server.Process.Kill() + server.Wait() + }() + time.Sleep(300 * time.Millisecond) + tests, _ := filepath.Glob(filepath.Join(root, "typesinfo.[0-9]*")) + sort.Strings(tests) + pass := 0 + for _, dir := range tests { + if st, err := os.Stat(dir); err != nil || !st.IsDir() { + continue + } + cursor := cursorOf(dir) + file := filepath.Join(dir, "test.go.in") + gotBytes, _ := command(bin, "-sock", "tcp", "-addr", addr, "-in", file, "liteide_typesinfo", file, strconv.Itoa(cursor)) + got := normalize(string(gotBytes), file) + want, _ := os.ReadFile(filepath.Join(dir, "out.expected")) + if got != string(want) { + fmt.Printf("%s: FAIL!\nGot:\n%sExpected:\n%s", filepath.Base(dir), got, want) + } else { + fmt.Printf("%s: PASS!\n", filepath.Base(dir)) + pass++ + } + } + fmt.Printf("\nSummary (total: %d)\n PASS: %d\n FAIL: %d\n", len(tests), pass, len(tests)-pass) + return pass == len(tests) +} + +func command(bin string, args ...string) ([]byte, error) { return exec.Command(bin, args...).Output() } +func cursorOf(dir string) int { + files, _ := filepath.Glob(filepath.Join(dir, "cursor.*")) + p := strings.Split(filepath.Base(files[0]), ".") + n, _ := strconv.Atoi(p[len(p)-1]) + if source, err := os.ReadFile(filepath.Join(dir, "test.go.in")); err == nil && bytesBeforeCursor(source, n) { + for i := 0; i < n && i+1 < len(source); i++ { + if source[i] == '\r' && source[i+1] == '\n' { + n++ + } + } + } + return n +} + +func bytesBeforeCursor(source []byte, cursor int) bool { + return cursor >= 0 && cursor <= len(source) && bytes.Index(source[:cursor], []byte("\r\n")) >= 0 +} +func goVersion() string { + b, _ := exec.Command("go", "env", "GOVERSION").Output() + return strings.TrimPrefix(strings.TrimSpace(string(b)), "go") +} +func expectedPath(dir, version, platform string) string { + parts := strings.Split(version, ".") + if len(parts) >= 2 { + mm := strings.Join(parts[:2], ".") + p := filepath.Join(dir, "out.expected.go"+mm+platform) + if _, err := os.Stat(p); err == nil { + return p + } + p = filepath.Join(dir, "out.expected.go"+mm) + if _, err := os.Stat(p); err == nil { + return p + } + } + return filepath.Join(dir, "out.expected") +} +func normalize(s, file string) string { + s = strings.ReplaceAll(s, "\\", "/") + if absolute, err := filepath.Abs(file); err == nil { + s = strings.ReplaceAll(s, filepath.ToSlash(absolute), "FILE") + } + for _, root := range []string{os.Getenv("GOROOT"), goroot()} { + if root != "" { + s = strings.ReplaceAll(s, filepath.ToSlash(root), "GOROOT") + } + } + s = regexp.MustCompile(`GOROOT/src/([^:]+):[0-9]+:[0-9]+`).ReplaceAllString(s, "GOROOT/src/$1:LINE:COLUMN") + return s +} +func goroot() string { + b, _ := exec.Command("go", "env", "GOROOT").Output() + return strings.TrimSpace(string(b)) +} +func fail(format string, args ...interface{}) { + fmt.Fprintf(os.Stderr, format+"\n", args...) + os.Exit(1) +} diff --git a/_testing/run.rb b/_testing/run.rb index 81b5d522..6cd96b83 100755 --- a/_testing/run.rb +++ b/_testing/run.rb @@ -10,6 +10,11 @@ Stats = Struct.new :total, :ok, :fail $stats = Stats.new 0, 0, 0 +require "open3" +root = File.expand_path(__dir__) +names = Gem.win_platform? ? %w[gocode.exe gocode] : %w[gocode] +$gocode = names.map { |name| File.join(root, name) }.find { |path| File.file?(path) } +abort "gocode binary not found in #{root}" unless $gocode def print_fail_report(t, out, outexpected) puts "#{t}: #{FAIL}" @@ -37,12 +42,16 @@ def run_test(t) cursorpos = Dir["#{t}/cursor.*"].map{|d| File.extname(d)[1..-1]}.first version = `go env GOVERSION 2>/dev/null`.strip.sub(/^go/, '') major_minor = version.split('.')[0, 2].join('.') - versioned = "#{t}/out.expected.go#{major_minor}" + windows = ENV["RUNNER_OS"] == "Windows" || File::ALT_SEPARATOR == "\\" || ENV["OS"] == "Windows_NT" || Gem.win_platform? || RUBY_PLATFORM =~ /mingw|mswin|msys/ + platform = windows ? ".windows" : "" + versioned = "#{t}/out.expected.go#{major_minor}#{platform}" + versioned = "#{t}/out.expected.go#{major_minor}" unless File.file?(versioned) expected_file = File.file?(versioned) ? versioned : "#{t}/out.expected" outexpected = IO.read(expected_file) rescue "To be determined" filename = "#{t}/test.go.in" - out = %x[gocode -in #{filename} autocomplete #{filename} #{cursorpos}] + out, status = Open3.capture2($gocode, "-in", filename, "autocomplete", filename, cursorpos.to_s) + out = "" unless status.success? if out != outexpected then print_fail_report(t, out, outexpected) @@ -62,3 +71,4 @@ def run_test(t) end print_stats +exit($stats.fail == 0 ? 0 : 1) diff --git a/_testing/run_test.go b/_testing/run_test.go new file mode 100644 index 00000000..51663d8d --- /dev/null +++ b/_testing/run_test.go @@ -0,0 +1,34 @@ +package main + +import ( + "os" + "path/filepath" + "testing" +) + +func testBinary(t *testing.T) string { + t.Helper() + for _, name := range []string{"gocode", "gocode.exe"} { + path := filepath.Join(".", name) + if _, err := os.Stat(path); err == nil { + absolute, err := filepath.Abs(path) + if err == nil { + return absolute + } + return path + } + } + t.Fatalf("gocode binary not found") + return "" +} + +func TestAutocomplete(t *testing.T) { + if !runAutocomplete(".", testBinary(t)) { + t.Fail() + } +} +func TestTypesInfo(t *testing.T) { + if !runTypesInfo(".", testBinary(t)) { + t.Fail() + } +} diff --git a/_testing/test.0001/out.expected.go1.26 b/_testing/test.0001/out.expected.go1.26 index 55068de5..41c26ea4 100644 --- a/_testing/test.0001/out.expected.go1.26 +++ b/_testing/test.0001/out.expected.go1.26 @@ -2,7 +2,7 @@ Found 41 candidates: func Append(b []byte, a ...interface{}) []byte func Appendf(b []byte, format string, a ...interface{}) []byte func Appendln(b []byte, a ...interface{}) []byte - func Errorf(format string, a ...interface{}) error + func Errorf(format string, a ...interface{}) (err error) func Flag(c int) bool func Format(f fmt.State, verb rune) func FormatString(state fmt.State, verb rune) string diff --git a/_testing/test.0001/out.expected.go1.26.windows b/_testing/test.0001/out.expected.go1.26.windows new file mode 100644 index 00000000..41c26ea4 --- /dev/null +++ b/_testing/test.0001/out.expected.go1.26.windows @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0001/out.expected.go1.27.windows b/_testing/test.0001/out.expected.go1.27.windows new file mode 100644 index 00000000..41c26ea4 --- /dev/null +++ b/_testing/test.0001/out.expected.go1.27.windows @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0007/out.expected.go1.25.windows b/_testing/test.0007/out.expected.go1.25.windows new file mode 100644 index 00000000..e95dadca --- /dev/null +++ b/_testing/test.0007/out.expected.go1.25.windows @@ -0,0 +1,10 @@ +Found 9 candidates: + var ForkLock sync.RWMutex + var OID_PKIX_KP_SERVER_AUTH []byte + var OID_SERVER_GATED_CRYPTO []byte + var OID_SGC_NETSCAPE []byte + var SocketDisableIPv6 bool + var Stderr syscall.Handle + var Stdin syscall.Handle + var Stdout syscall.Handle + var WSAID_CONNECTEX syscall.GUID diff --git a/_testing/test.0007/out.expected.go1.26.windows b/_testing/test.0007/out.expected.go1.26.windows new file mode 100644 index 00000000..e95dadca --- /dev/null +++ b/_testing/test.0007/out.expected.go1.26.windows @@ -0,0 +1,10 @@ +Found 9 candidates: + var ForkLock sync.RWMutex + var OID_PKIX_KP_SERVER_AUTH []byte + var OID_SERVER_GATED_CRYPTO []byte + var OID_SGC_NETSCAPE []byte + var SocketDisableIPv6 bool + var Stderr syscall.Handle + var Stdin syscall.Handle + var Stdout syscall.Handle + var WSAID_CONNECTEX syscall.GUID diff --git a/_testing/test.0007/out.expected.go1.27.windows b/_testing/test.0007/out.expected.go1.27.windows new file mode 100644 index 00000000..e95dadca --- /dev/null +++ b/_testing/test.0007/out.expected.go1.27.windows @@ -0,0 +1,10 @@ +Found 9 candidates: + var ForkLock sync.RWMutex + var OID_PKIX_KP_SERVER_AUTH []byte + var OID_SERVER_GATED_CRYPTO []byte + var OID_SGC_NETSCAPE []byte + var SocketDisableIPv6 bool + var Stderr syscall.Handle + var Stdin syscall.Handle + var Stdout syscall.Handle + var WSAID_CONNECTEX syscall.GUID diff --git a/_testing/test.0011/out.expected.go1.26 b/_testing/test.0011/out.expected.go1.26 index f4e24d72..40c225e7 100644 --- a/_testing/test.0011/out.expected.go1.26 +++ b/_testing/test.0011/out.expected.go1.26 @@ -1,4 +1,4 @@ -Found 103 candidates: +Found 105 candidates: func Addr() reflect.Value func Bool() bool func Bytes() []byte @@ -15,7 +15,7 @@ Found 103 candidates: func Cap() int func Clear() func Close() - func Comparable() bool + func Comparable() (#rv1 bool) func Complex() complex128 func Convert(t reflect.Type) reflect.Value func Elem() reflect.Value @@ -25,6 +25,7 @@ Found 103 candidates: func FieldByIndexErr(index []int) (reflect.Value, error) func FieldByName(name string) reflect.Value func FieldByNameFunc(match func(string) bool) reflect.Value + func Fields() (iter.Seq2[reflect.StructField, reflect.Value]) func Float() float64 func Grow(n int) func Index(i int) reflect.Value @@ -41,6 +42,7 @@ Found 103 candidates: func MapRange() *reflect.MapIter func Method(i int) reflect.Value func MethodByName(name string) reflect.Value + func Methods() (iter.Seq2[reflect.Method, reflect.Value]) func NumField() int func NumMethod() int func OverflowComplex(x complex128) bool diff --git a/_testing/test.0011/out.expected.go1.26.windows b/_testing/test.0011/out.expected.go1.26.windows new file mode 100644 index 00000000..ad1e3808 --- /dev/null +++ b/_testing/test.0011/out.expected.go1.26.windows @@ -0,0 +1,124 @@ +Found 105 candidates: + func Addr() reflect.Value + func Bool() bool + func Bytes() []byte + func Call(in []reflect.Value) []reflect.Value + func CallSlice(in []reflect.Value) []reflect.Value + func CanAddr() bool + func CanComplex() bool + func CanConvert(t reflect.Type) bool + func CanFloat() bool + func CanInt() bool + func CanInterface() bool + func CanSet() bool + func CanUint() bool + func Cap() int + func Clear() + func Close() + func Comparable() (#rv1 bool) + func Complex() complex128 + func Convert(t reflect.Type) reflect.Value + func Elem() reflect.Value + func Equal(u reflect.Value) bool + func Field(i int) reflect.Value + func FieldByIndex(index []int) reflect.Value + func FieldByIndexErr(index []int) (reflect.Value, error) + func FieldByName(name string) reflect.Value + func FieldByNameFunc(match func(string) bool) reflect.Value + func Fields() (iter.Seq2[reflect.StructField, reflect.Value]) + func Float() float64 + func Grow(n int) + func Index(i int) reflect.Value + func Int() int64 + func Interface() (i interface{}) + func InterfaceData() [2]uintptr + func IsNil() bool + func IsValid() bool + func IsZero() bool + func Kind() reflect.Kind + func Len() int + func MapIndex(key reflect.Value) reflect.Value + func MapKeys() []reflect.Value + func MapRange() *reflect.MapIter + func Method(i int) reflect.Value + func MethodByName(name string) reflect.Value + func Methods() (iter.Seq2[reflect.Method, reflect.Value]) + func NumField() int + func NumMethod() int + func OverflowComplex(x complex128) bool + func OverflowFloat(x float64) bool + func OverflowInt(x int64) bool + func OverflowUint(x uint64) bool + func Pointer() uintptr + func Recv() (x reflect.Value, ok bool) + func Send(x reflect.Value) + func Seq() iter.Seq[reflect.Value] + func Seq2() (iter.Seq2[reflect.Value, reflect.Value]) + func Set(x reflect.Value) + func SetBool(x bool) + func SetBytes(x []byte) + func SetCap(n int) + func SetComplex(x complex128) + func SetFloat(x float64) + func SetInt(x int64) + func SetIterKey(iter *reflect.MapIter) + func SetIterValue(iter *reflect.MapIter) + func SetLen(n int) + func SetMapIndex(key reflect.Value, elem reflect.Value) + func SetPointer(x unsafe.Pointer) + func SetString(x string) + func SetUint(x uint64) + func SetZero() + func Slice(i int, j int) reflect.Value + func Slice3(i int, j int, k int) reflect.Value + func String() string + func TryRecv() (x reflect.Value, ok bool) + func TrySend(x reflect.Value) bool + func Type() reflect.Type + func Uint() uint64 + func UnsafeAddr() uintptr + func UnsafePointer() unsafe.Pointer + func abiType() *abi.Type + func abiTypeSlow() *abi.Type + func assignTo(context string, dst *abi.Type, target unsafe.Pointer) reflect.Value + func bytesSlow() []byte + func call(op string, in []reflect.Value) []reflect.Value + func capNonSlice() int + func extendSlice(n int) reflect.Value + func grow(n int) + func kind() reflect.Kind + func lenNonSlice() int + func mustBe(expected reflect.Kind) + func mustBeAssignable() + func mustBeAssignableSlow() + func mustBeExported() + func mustBeExportedSlow() + func panicNotBool() + func panicNotMap() + func pointer() unsafe.Pointer + func recv(nb bool) (val reflect.Value, ok bool) + func ro() reflect.flag + func runes() []rune + func send(x reflect.Value, nb bool) (selected bool) + func setRunes(x []rune) + func stringNonString() string + func typ() *abi.Type + func typeSlow() reflect.Type +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. diff --git a/_testing/test.0011/out.expected.go1.27.windows b/_testing/test.0011/out.expected.go1.27.windows new file mode 100644 index 00000000..ad1e3808 --- /dev/null +++ b/_testing/test.0011/out.expected.go1.27.windows @@ -0,0 +1,124 @@ +Found 105 candidates: + func Addr() reflect.Value + func Bool() bool + func Bytes() []byte + func Call(in []reflect.Value) []reflect.Value + func CallSlice(in []reflect.Value) []reflect.Value + func CanAddr() bool + func CanComplex() bool + func CanConvert(t reflect.Type) bool + func CanFloat() bool + func CanInt() bool + func CanInterface() bool + func CanSet() bool + func CanUint() bool + func Cap() int + func Clear() + func Close() + func Comparable() (#rv1 bool) + func Complex() complex128 + func Convert(t reflect.Type) reflect.Value + func Elem() reflect.Value + func Equal(u reflect.Value) bool + func Field(i int) reflect.Value + func FieldByIndex(index []int) reflect.Value + func FieldByIndexErr(index []int) (reflect.Value, error) + func FieldByName(name string) reflect.Value + func FieldByNameFunc(match func(string) bool) reflect.Value + func Fields() (iter.Seq2[reflect.StructField, reflect.Value]) + func Float() float64 + func Grow(n int) + func Index(i int) reflect.Value + func Int() int64 + func Interface() (i interface{}) + func InterfaceData() [2]uintptr + func IsNil() bool + func IsValid() bool + func IsZero() bool + func Kind() reflect.Kind + func Len() int + func MapIndex(key reflect.Value) reflect.Value + func MapKeys() []reflect.Value + func MapRange() *reflect.MapIter + func Method(i int) reflect.Value + func MethodByName(name string) reflect.Value + func Methods() (iter.Seq2[reflect.Method, reflect.Value]) + func NumField() int + func NumMethod() int + func OverflowComplex(x complex128) bool + func OverflowFloat(x float64) bool + func OverflowInt(x int64) bool + func OverflowUint(x uint64) bool + func Pointer() uintptr + func Recv() (x reflect.Value, ok bool) + func Send(x reflect.Value) + func Seq() iter.Seq[reflect.Value] + func Seq2() (iter.Seq2[reflect.Value, reflect.Value]) + func Set(x reflect.Value) + func SetBool(x bool) + func SetBytes(x []byte) + func SetCap(n int) + func SetComplex(x complex128) + func SetFloat(x float64) + func SetInt(x int64) + func SetIterKey(iter *reflect.MapIter) + func SetIterValue(iter *reflect.MapIter) + func SetLen(n int) + func SetMapIndex(key reflect.Value, elem reflect.Value) + func SetPointer(x unsafe.Pointer) + func SetString(x string) + func SetUint(x uint64) + func SetZero() + func Slice(i int, j int) reflect.Value + func Slice3(i int, j int, k int) reflect.Value + func String() string + func TryRecv() (x reflect.Value, ok bool) + func TrySend(x reflect.Value) bool + func Type() reflect.Type + func Uint() uint64 + func UnsafeAddr() uintptr + func UnsafePointer() unsafe.Pointer + func abiType() *abi.Type + func abiTypeSlow() *abi.Type + func assignTo(context string, dst *abi.Type, target unsafe.Pointer) reflect.Value + func bytesSlow() []byte + func call(op string, in []reflect.Value) []reflect.Value + func capNonSlice() int + func extendSlice(n int) reflect.Value + func grow(n int) + func kind() reflect.Kind + func lenNonSlice() int + func mustBe(expected reflect.Kind) + func mustBeAssignable() + func mustBeAssignableSlow() + func mustBeExported() + func mustBeExportedSlow() + func panicNotBool() + func panicNotMap() + func pointer() unsafe.Pointer + func recv(nb bool) (val reflect.Value, ok bool) + func ro() reflect.flag + func runes() []rune + func send(x reflect.Value, nb bool) (selected bool) + func setRunes(x []rune) + func stringNonString() string + func typ() *abi.Type + func typeSlow() reflect.Type +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. diff --git a/_testing/test.0023/out.expected.go1.26 b/_testing/test.0023/out.expected.go1.26 index 55068de5..41c26ea4 100644 --- a/_testing/test.0023/out.expected.go1.26 +++ b/_testing/test.0023/out.expected.go1.26 @@ -2,7 +2,7 @@ Found 41 candidates: func Append(b []byte, a ...interface{}) []byte func Appendf(b []byte, format string, a ...interface{}) []byte func Appendln(b []byte, a ...interface{}) []byte - func Errorf(format string, a ...interface{}) error + func Errorf(format string, a ...interface{}) (err error) func Flag(c int) bool func Format(f fmt.State, verb rune) func FormatString(state fmt.State, verb rune) string diff --git a/_testing/test.0023/out.expected.go1.26.windows b/_testing/test.0023/out.expected.go1.26.windows new file mode 100644 index 00000000..41c26ea4 --- /dev/null +++ b/_testing/test.0023/out.expected.go1.26.windows @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0023/out.expected.go1.27.windows b/_testing/test.0023/out.expected.go1.27.windows new file mode 100644 index 00000000..41c26ea4 --- /dev/null +++ b/_testing/test.0023/out.expected.go1.27.windows @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0029/out.expected.go1.26 b/_testing/test.0029/out.expected.go1.26 index 12a41baf..d3293862 100644 --- a/_testing/test.0029/out.expected.go1.26 +++ b/_testing/test.0029/out.expected.go1.26 @@ -2,7 +2,7 @@ Found 43 candidates: func Append(b []byte, a ...interface{}) []byte func Appendf(b []byte, format string, a ...interface{}) []byte func Appendln(b []byte, a ...interface{}) []byte - func Errorf(format string, a ...interface{}) error + func Errorf(format string, a ...interface{}) (err error) func Flag(c int) bool func Format(f fmt.State, verb rune) func FormatString(state fmt.State, verb rune) string diff --git a/_testing/test.0029/out.expected.go1.26.windows b/_testing/test.0029/out.expected.go1.26.windows new file mode 100644 index 00000000..9b297267 --- /dev/null +++ b/_testing/test.0029/out.expected.go1.26.windows @@ -0,0 +1,61 @@ +Found 43 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + func main() + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface + var a Formatter +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. diff --git a/_testing/test.0029/out.expected.go1.27.windows b/_testing/test.0029/out.expected.go1.27.windows new file mode 100644 index 00000000..9b297267 --- /dev/null +++ b/_testing/test.0029/out.expected.go1.27.windows @@ -0,0 +1,61 @@ +Found 43 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + func main() + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface + var a Formatter +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. diff --git a/_testing/test.0045/out.expected.go1.26 b/_testing/test.0045/out.expected.go1.26 index 55068de5..41c26ea4 100644 --- a/_testing/test.0045/out.expected.go1.26 +++ b/_testing/test.0045/out.expected.go1.26 @@ -2,7 +2,7 @@ Found 41 candidates: func Append(b []byte, a ...interface{}) []byte func Appendf(b []byte, format string, a ...interface{}) []byte func Appendln(b []byte, a ...interface{}) []byte - func Errorf(format string, a ...interface{}) error + func Errorf(format string, a ...interface{}) (err error) func Flag(c int) bool func Format(f fmt.State, verb rune) func FormatString(state fmt.State, verb rune) string diff --git a/_testing/test.0045/out.expected.go1.26.windows b/_testing/test.0045/out.expected.go1.26.windows new file mode 100644 index 00000000..41c26ea4 --- /dev/null +++ b/_testing/test.0045/out.expected.go1.26.windows @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0045/out.expected.go1.27.windows b/_testing/test.0045/out.expected.go1.27.windows new file mode 100644 index 00000000..41c26ea4 --- /dev/null +++ b/_testing/test.0045/out.expected.go1.27.windows @@ -0,0 +1,42 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface diff --git a/_testing/test.0046/out.expected.go1.26 b/_testing/test.0046/out.expected.go1.26 index 55068de5..41c26ea4 100644 --- a/_testing/test.0046/out.expected.go1.26 +++ b/_testing/test.0046/out.expected.go1.26 @@ -2,7 +2,7 @@ Found 41 candidates: func Append(b []byte, a ...interface{}) []byte func Appendf(b []byte, format string, a ...interface{}) []byte func Appendln(b []byte, a ...interface{}) []byte - func Errorf(format string, a ...interface{}) error + func Errorf(format string, a ...interface{}) (err error) func Flag(c int) bool func Format(f fmt.State, verb rune) func FormatString(state fmt.State, verb rune) string diff --git a/_testing/test.0046/out.expected.go1.26.windows b/_testing/test.0046/out.expected.go1.26.windows new file mode 100644 index 00000000..394d1819 --- /dev/null +++ b/_testing/test.0046/out.expected.go1.26.windows @@ -0,0 +1,84 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. diff --git a/_testing/test.0046/out.expected.go1.27.windows b/_testing/test.0046/out.expected.go1.27.windows new file mode 100644 index 00000000..394d1819 --- /dev/null +++ b/_testing/test.0046/out.expected.go1.27.windows @@ -0,0 +1,84 @@ +Found 41 candidates: + func Append(b []byte, a ...interface{}) []byte + func Appendf(b []byte, format string, a ...interface{}) []byte + func Appendln(b []byte, a ...interface{}) []byte + func Errorf(format string, a ...interface{}) (err error) + func Flag(c int) bool + func Format(f fmt.State, verb rune) + func FormatString(state fmt.State, verb rune) string + func Fprint(w io.Writer, a ...interface{}) (n int, err error) + func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) + func Fprintln(w io.Writer, a ...interface{}) (n int, err error) + func Fscan(r io.Reader, a ...interface{}) (n int, err error) + func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) + func Fscanln(r io.Reader, a ...interface{}) (n int, err error) + func GoString() string + func Precision() (prec int, ok bool) + func Print(a ...interface{}) (n int, err error) + func Printf(format string, a ...interface{}) (n int, err error) + func Println(a ...interface{}) (n int, err error) + func Read(buf []byte) (n int, err error) + func ReadRune() (r rune, size int, err error) + func Scan(a ...interface{}) (n int, err error) + func Scanf(format string, a ...interface{}) (n int, err error) + func Scanln(a ...interface{}) (n int, err error) + func SkipSpace() + func Sprint(a ...interface{}) string + func Sprintf(format string, a ...interface{}) string + func Sprintln(a ...interface{}) string + func Sscan(str string, a ...interface{}) (n int, err error) + func Sscanf(str string, format string, a ...interface{}) (n int, err error) + func Sscanln(str string, a ...interface{}) (n int, err error) + func String() string + func Token(skipSpace bool, f func(rune) bool) (token []byte, err error) + func UnreadRune() error + func Width() (wid int, ok bool) + func Write(b []byte) (n int, err error) + type Formatter interface + type GoStringer interface + type ScanState interface + type Scanner interface + type State interface + type Stringer interface +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. +The system cannot find the path specified. diff --git a/_testing/test.0081/out.expected.go1.27.windows b/_testing/test.0081/out.expected.go1.27.windows new file mode 100644 index 00000000..e6615376 --- /dev/null +++ b/_testing/test.0081/out.expected.go1.27.windows @@ -0,0 +1,3 @@ +Found 2 candidates: + func Map(v U) U + var Value int diff --git a/_testing/test.0082/out.expected.go1.27.windows b/_testing/test.0082/out.expected.go1.27.windows new file mode 100644 index 00000000..75363209 --- /dev/null +++ b/_testing/test.0082/out.expected.go1.27.windows @@ -0,0 +1,3 @@ +Found 2 candidates: + func Convert(v U) Result[U] + var Value int diff --git a/_testing/test.0083/out.expected.go1.27.windows b/_testing/test.0083/out.expected.go1.27.windows new file mode 100644 index 00000000..9ec30f0d --- /dev/null +++ b/_testing/test.0083/out.expected.go1.27.windows @@ -0,0 +1,4 @@ +Found 3 candidates: + func Swap(c C, d D) (Pair[D, C]) + var First int + var Second string diff --git a/_testing/typesinfo.rb b/_testing/typesinfo.rb index 8f7eef14..e58d5842 100644 --- a/_testing/typesinfo.rb +++ b/_testing/typesinfo.rb @@ -6,16 +6,27 @@ NC = "\033[0m" root = File.expand_path(__dir__) +require "socket" +require "open3" +require "timeout" +binary_names = Gem.win_platform? ? %w[gocode.exe gocode] : %w[gocode] +binary = binary_names.map { |name| File.join(root, name) }.find { |path| File.file?(path) } +abort "gocode binary not found in #{root}" unless binary port = 40000 + (Process.pid % 1000) addr = "127.0.0.1:#{port}" -server = Process.spawn("gocode", "-s", "-sock", "tcp", "-addr", addr, +server = Process.spawn(binary, "-s", "-sock", "tcp", "-addr", addr, chdir: root, out: File::NULL, err: File::NULL) at_exit do - Process.kill("TERM", server) rescue nil - Process.wait(server) rescue nil + Open3.capture2(binary, "-sock", "tcp", "-addr", addr, "close") rescue nil + if Gem.win_platform? + system("taskkill", "/PID", server.to_s, "/T", "/F", out: File::NULL, err: File::NULL) + else + Process.kill("TERM", server) rescue nil + end + Timeout.timeout(5) { Process.wait(server) } +rescue Timeout::Error end -require "socket" 100.times do begin TCPSocket.new("127.0.0.1", port).close @@ -31,11 +42,19 @@ next unless File.directory?(dir) total += 1 file = File.join(dir, "test.go.in") - cursor = Dir[File.join(dir, "cursor.*")].first.split(".").last + cursor = Dir[File.join(dir, "cursor.*")].first.split(".").last.to_i + source = File.binread(file) + cursor += source.byteslice(0, cursor).count("\n") if source.include?("\r\n") expected = File.read(File.join(dir, "out.expected")) - out = `gocode -sock tcp -addr #{addr} -in #{file} liteide_typesinfo #{file} #{cursor}` - out = out.gsub(File.expand_path(file), "FILE") - out = out.gsub(%r{/.*/go\d+\.\d+/src/}, "GOROOT/src/") + out, status = Open3.capture2(binary, "-sock", "tcp", "-addr", addr, + "-in", file, "liteide_typesinfo", file, cursor.to_s) + out = "" unless status.success? + out = out.tr("\\", "/") + out = out.gsub(File.expand_path(file).tr("\\", "/"), "FILE") + goroot = ENV["GOROOT"] || `go env GOROOT`.strip + out = out.gsub(goroot, "GOROOT") + out = out.gsub(%r{.*/go/(?:\d+\.)+\d+/(?:[^/]+/)?src/}, "GOROOT/src/") + out = out.gsub(%r{.*/go\d+(?:\.\d+)+/(?:[^/]+/)?src/}, "GOROOT/src/") out = out.gsub(%r{GOROOT/src/([^:]+):\d+:\d+}, 'GOROOT/src/\\1:LINE:COLUMN') if out == expected puts "#{File.basename(dir)}: #{GRN}PASS!#{NC}" diff --git a/go.mod b/go.mod index 8d7c5265..efbb94a1 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/visualfc/gocode go 1.25.0 require ( - github.com/visualfc/gotools v1.5.5-0.20260829095928-37d050d3eb58 + github.com/visualfc/gotools v1.6.0 golang.org/x/tools v0.49.0 ) diff --git a/go.sum b/go.sum index 7751c0e6..8acfd665 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,8 @@ github.com/visualfc/gotools v1.5.4 h1:ydm1Kb+UCylRxOCKjWjC9sXQfvQG8/khxygzLwnORD github.com/visualfc/gotools v1.5.4/go.mod h1:VlP59ccCsSmRbFZTbuHgQDrTOi40EGKvyFK2Cq2Far8= github.com/visualfc/gotools v1.5.5-0.20260829095928-37d050d3eb58 h1:GpU5lDGZA2gegH0HMI6NtDi2l+05dislHJ6RaceX+RQ= github.com/visualfc/gotools v1.5.5-0.20260829095928-37d050d3eb58/go.mod h1:ymCj4CUbObE6C/PBz4DqF8AoI53GRnSu99JfxDf4htI= +github.com/visualfc/gotools v1.6.0 h1:YAYWNqVxROrOoa+nIbenhOKHTAg6pRfkKpizHQT1dTo= +github.com/visualfc/gotools v1.6.0/go.mod h1:ymCj4CUbObE6C/PBz4DqF8AoI53GRnSu99JfxDf4htI= github.com/visualfc/goversion v1.1.0 h1:EN0YQGRkeGoWTPxPNTnbhyNQyas5leKH5U5lL4t8lRE= github.com/visualfc/goversion v1.1.0/go.mod h1:Gr3s6bW8NTomhheImwAttqno97Mw6pAnFn2dU8/EMa8= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= From 7b4cadaacebb5da4e68ddf2e9ff988459a5dd57d Mon Sep 17 00:00:00 2001 From: visualfc Date: Sun, 30 Aug 2026 09:12:18 +0800 Subject: [PATCH 08/11] fix Windows test binary name --- .github/workflows/go.yml | 7 ++++++- _testing/run.go | 4 +--- _testing/run_test.go | 19 +++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 469a087d..74e99049 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -21,9 +21,14 @@ jobs: with: go-version: ${{ matrix.go-version }} - - name: Build + - name: Build (Unix) + if: runner.os != 'Windows' run: go build -v -o _testing/gocode + - name: Build (Windows) + if: runner.os == 'Windows' + run: go build -v -o _testing/gocode.exe + - name: Regression tests working-directory: _testing run: go test -v diff --git a/_testing/run.go b/_testing/run.go index 151abb97..de31c911 100644 --- a/_testing/run.go +++ b/_testing/run.go @@ -22,9 +22,7 @@ func main() { root, _ := os.Getwd() bin := filepath.Join(root, "gocode") if runtime.GOOS == "windows" { - if _, err := os.Stat(bin + ".exe"); err == nil { - bin += ".exe" - } + bin = filepath.Join(root, "gocode.exe") } if _, err := os.Stat(bin); err != nil { fail("gocode binary not found: %v", err) diff --git a/_testing/run_test.go b/_testing/run_test.go index 51663d8d..483cb93b 100644 --- a/_testing/run_test.go +++ b/_testing/run_test.go @@ -3,20 +3,23 @@ package main import ( "os" "path/filepath" + "runtime" "testing" ) func testBinary(t *testing.T) string { t.Helper() - for _, name := range []string{"gocode", "gocode.exe"} { - path := filepath.Join(".", name) - if _, err := os.Stat(path); err == nil { - absolute, err := filepath.Abs(path) - if err == nil { - return absolute - } - return path + name := "gocode" + if runtime.GOOS == "windows" { + name = "gocode.exe" + } + path := filepath.Join(".", name) + if _, err := os.Stat(path); err == nil { + absolute, err := filepath.Abs(path) + if err == nil { + return absolute } + return path } t.Fatalf("gocode binary not found") return "" From 244e8cd8476a3a88d64979152351712b367bacef Mon Sep 17 00:00:00 2001 From: visualfc Date: Sun, 30 Aug 2026 09:18:29 +0800 Subject: [PATCH 09/11] remove stale Windows test output --- .../test.0011/out.expected.go1.26.windows | 18 -------- .../test.0011/out.expected.go1.27.windows | 18 -------- .../test.0029/out.expected.go1.26.windows | 17 -------- .../test.0029/out.expected.go1.27.windows | 17 -------- .../test.0046/out.expected.go1.26.windows | 42 ------------------- .../test.0046/out.expected.go1.27.windows | 42 ------------------- 6 files changed, 154 deletions(-) diff --git a/_testing/test.0011/out.expected.go1.26.windows b/_testing/test.0011/out.expected.go1.26.windows index ad1e3808..40c225e7 100644 --- a/_testing/test.0011/out.expected.go1.26.windows +++ b/_testing/test.0011/out.expected.go1.26.windows @@ -104,21 +104,3 @@ Found 105 candidates: func stringNonString() string func typ() *abi.Type func typeSlow() reflect.Type -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. diff --git a/_testing/test.0011/out.expected.go1.27.windows b/_testing/test.0011/out.expected.go1.27.windows index ad1e3808..40c225e7 100644 --- a/_testing/test.0011/out.expected.go1.27.windows +++ b/_testing/test.0011/out.expected.go1.27.windows @@ -104,21 +104,3 @@ Found 105 candidates: func stringNonString() string func typ() *abi.Type func typeSlow() reflect.Type -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. diff --git a/_testing/test.0029/out.expected.go1.26.windows b/_testing/test.0029/out.expected.go1.26.windows index 9b297267..d3293862 100644 --- a/_testing/test.0029/out.expected.go1.26.windows +++ b/_testing/test.0029/out.expected.go1.26.windows @@ -42,20 +42,3 @@ Found 43 candidates: type State interface type Stringer interface var a Formatter -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. diff --git a/_testing/test.0029/out.expected.go1.27.windows b/_testing/test.0029/out.expected.go1.27.windows index 9b297267..d3293862 100644 --- a/_testing/test.0029/out.expected.go1.27.windows +++ b/_testing/test.0029/out.expected.go1.27.windows @@ -42,20 +42,3 @@ Found 43 candidates: type State interface type Stringer interface var a Formatter -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. diff --git a/_testing/test.0046/out.expected.go1.26.windows b/_testing/test.0046/out.expected.go1.26.windows index 394d1819..41c26ea4 100644 --- a/_testing/test.0046/out.expected.go1.26.windows +++ b/_testing/test.0046/out.expected.go1.26.windows @@ -40,45 +40,3 @@ Found 41 candidates: type Scanner interface type State interface type Stringer interface -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. diff --git a/_testing/test.0046/out.expected.go1.27.windows b/_testing/test.0046/out.expected.go1.27.windows index 394d1819..41c26ea4 100644 --- a/_testing/test.0046/out.expected.go1.27.windows +++ b/_testing/test.0046/out.expected.go1.27.windows @@ -40,45 +40,3 @@ Found 41 candidates: type Scanner interface type State interface type Stringer interface -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. -The system cannot find the path specified. From b48888b86664228709ca120f2c339c1309e4d884 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sun, 30 Aug 2026 09:22:22 +0800 Subject: [PATCH 10/11] remove obsolete test runners --- _testing/all.bash | 12 ------- _testing/run.py | 67 ------------------------------------- _testing/run.rb | 74 ---------------------------------------- _testing/run.tcl | 78 ------------------------------------------- _testing/typesinfo.rb | 70 -------------------------------------- 5 files changed, 301 deletions(-) delete mode 100755 _testing/all.bash delete mode 100755 _testing/run.py delete mode 100755 _testing/run.rb delete mode 100755 _testing/run.tcl delete mode 100644 _testing/typesinfo.rb diff --git a/_testing/all.bash b/_testing/all.bash deleted file mode 100755 index d3b7a0ae..00000000 --- a/_testing/all.bash +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -go build ../. -./gocode close -sleep 0.5 -echo "--------------------------------------------------------------------" -echo "Autocompletion tests..." -echo "--------------------------------------------------------------------" -export XDG_CONFIG_HOME="$(mktemp -d)" -./run.rb -sleep 0.5 -./gocode close -rm ./gocode diff --git a/_testing/run.py b/_testing/run.py deleted file mode 100755 index f77ed283..00000000 --- a/_testing/run.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 - -import os, glob, subprocess, sys - -total = 0 -ok = 0 -fail = 0 -expected_fail = 0 - -RED = "\033[0;31m" -GREEN = "\033[0;32m" -YELLOW = "\033[0;33m" -NC = "\033[0m" - -OK = GREEN + "PASS!" + NC -FAIL = RED + "FAIL!" + NC -EXPECTED = YELLOW + "EXPECTED: " + NC - -# name of the test + commentary (why it is expected to fail) -expected_to_fail = { -} - -def run_test(t): - global total, ok, fail, expected_fail - total += 1 - c = glob.glob(t + "/cursor.*")[0] - cursorpos = os.path.splitext(c)[1][1:] - try: - with open(t + "/out.expected", "r") as f: - outexpected = f.read() - except: - outexpected = "To be determined" - filename = t + "/test.go.in" - gocode = subprocess.Popen(["gocode", "-in", filename, "autocomplete", filename, cursorpos], - shell=False, stdout=subprocess.PIPE) - out = gocode.communicate()[0] - if out != outexpected: - if t in expected_to_fail: - print t + ": " + FAIL + " " + EXPECTED + expected_to_fail[t] - expected_fail += 1 - else: - print t + ": " + FAIL - print "--------------------------------------------------------" - print "Got:\n" + out - print "--------------------------------------------------------" - print "Expected:\n" + outexpected - print "--------------------------------------------------------" - fail += 1 - else: - print t + ": " + OK - ok += 1 - -if len(sys.argv) == 2: - run_test(sys.argv[1]) -else: - for t in sorted(glob.glob("test.*")): - run_test(t) - -print "\nSummary (total: %d):" % total -print GREEN + " PASS" + NC + ": %d" % ok -print RED +" FAIL" + NC + ": %d (unexpected failures)" % fail - -if fail == 0: - print GREEN + "████████████████████████████████████████████████████████████████████" + NC -else: - print RED + "████████████████████████████████████████████████████████████████████" + NC diff --git a/_testing/run.rb b/_testing/run.rb deleted file mode 100755 index 6cd96b83..00000000 --- a/_testing/run.rb +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env ruby -# encoding: utf-8 - -RED = "\033[0;31m" -GRN = "\033[0;32m" -NC = "\033[0m" - -PASS = "#{GRN}PASS!#{NC}" -FAIL = "#{RED}FAIL!#{NC}" - -Stats = Struct.new :total, :ok, :fail -$stats = Stats.new 0, 0, 0 -require "open3" -root = File.expand_path(__dir__) -names = Gem.win_platform? ? %w[gocode.exe gocode] : %w[gocode] -$gocode = names.map { |name| File.join(root, name) }.find { |path| File.file?(path) } -abort "gocode binary not found in #{root}" unless $gocode - -def print_fail_report(t, out, outexpected) - puts "#{t}: #{FAIL}" - puts "-"*65 - puts "Got:\n#{out}" - puts "-"*65 - puts "Expected:\n#{outexpected}" - puts "-"*65 -end - -def print_pass_report(t) - puts "#{t}: #{PASS}" -end - -def print_stats - puts "\nSummary (total: #{$stats.total})" - puts "#{GRN} PASS#{NC}: #{$stats.ok}" - puts "#{RED} FAIL#{NC}: #{$stats.fail}" - puts "#{$stats.fail == 0 ? GRN : RED}#{"█"*72}#{NC}" -end - -def run_test(t) - $stats.total += 1 - - cursorpos = Dir["#{t}/cursor.*"].map{|d| File.extname(d)[1..-1]}.first - version = `go env GOVERSION 2>/dev/null`.strip.sub(/^go/, '') - major_minor = version.split('.')[0, 2].join('.') - windows = ENV["RUNNER_OS"] == "Windows" || File::ALT_SEPARATOR == "\\" || ENV["OS"] == "Windows_NT" || Gem.win_platform? || RUBY_PLATFORM =~ /mingw|mswin|msys/ - platform = windows ? ".windows" : "" - versioned = "#{t}/out.expected.go#{major_minor}#{platform}" - versioned = "#{t}/out.expected.go#{major_minor}" unless File.file?(versioned) - expected_file = File.file?(versioned) ? versioned : "#{t}/out.expected" - outexpected = IO.read(expected_file) rescue "To be determined" - filename = "#{t}/test.go.in" - - out, status = Open3.capture2($gocode, "-in", filename, "autocomplete", filename, cursorpos.to_s) - out = "" unless status.success? - - if out != outexpected then - print_fail_report(t, out, outexpected) - $stats.fail += 1 - else - print_pass_report(t) - $stats.ok += 1 - end -end - -if ARGV.one? - run_test ARGV[0] -else - Dir["test.*"].sort.each do |t| - run_test t - end -end - -print_stats -exit($stats.fail == 0 ? 0 : 1) diff --git a/_testing/run.tcl b/_testing/run.tcl deleted file mode 100755 index a2124042..00000000 --- a/_testing/run.tcl +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env tclsh - -set red "\033\[0;31m" -set grn "\033\[0;32m" -set nc "\033\[0m" - -set pass "${grn}PASS!${nc}" -set fail "${red}FAIL!${nc}" - -set stats.total 0 -set stats.ok 0 -set stats.fail 0 - -proc print_fail_report {t out expected} { - global fail - - set hr [join [lrepeat 65 "-"] ""] - puts "${t}: ${fail}" - puts $hr - puts "Got:\n${out}" - puts $hr - puts "Expected:\n${expected}" - puts $hr -} - -proc print_pass_report {t} { - global pass - - puts "${t}: ${pass}" -} - -proc print_stats {} { - global red grn nc stats.total stats.ok stats.fail - - set hr [join [lrepeat 72 "█"] ""] - set hrcol [expr {${stats.fail} ? $red : $grn}] - puts "\nSummary (total: ${stats.total})" - puts "${grn} PASS${nc}: ${stats.ok}" - puts "${red} FAIL${nc}: ${stats.fail}" - puts "${hrcol}${hr}${nc}" -} - -proc read_file {filename} { - set f [open $filename r] - set data [read $f] - close $f - return $data -} - -proc run_test {t} { - global stats.total stats.ok stats.fail - - incr stats.total - set cursorpos [string range [file extension [glob "${t}/cursor.*"]] 1 end] - set expected [read_file "${t}/out.expected"] - set filename "${t}/test.go.in" - - set out [read_file "| gocode -in ${filename} autocomplete ${filename} ${cursorpos}"] - if {$out eq $expected} { - print_pass_report $t - incr stats.ok - } else { - print_fail_report $t $out $expected - incr stats.fail - } -} - -if {$argc == 1} { - run_test $argv -} else { - foreach t [lsort [glob test.*]] { - run_test $t - } -} - -print_stats - - diff --git a/_testing/typesinfo.rb b/_testing/typesinfo.rb deleted file mode 100644 index e58d5842..00000000 --- a/_testing/typesinfo.rb +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env ruby -# encoding: utf-8 - -RED = "\033[0;31m" -GRN = "\033[0;32m" -NC = "\033[0m" - -root = File.expand_path(__dir__) -require "socket" -require "open3" -require "timeout" -binary_names = Gem.win_platform? ? %w[gocode.exe gocode] : %w[gocode] -binary = binary_names.map { |name| File.join(root, name) }.find { |path| File.file?(path) } -abort "gocode binary not found in #{root}" unless binary -port = 40000 + (Process.pid % 1000) -addr = "127.0.0.1:#{port}" -server = Process.spawn(binary, "-s", "-sock", "tcp", "-addr", addr, - chdir: root, out: File::NULL, err: File::NULL) -at_exit do - Open3.capture2(binary, "-sock", "tcp", "-addr", addr, "close") rescue nil - if Gem.win_platform? - system("taskkill", "/PID", server.to_s, "/T", "/F", out: File::NULL, err: File::NULL) - else - Process.kill("TERM", server) rescue nil - end - Timeout.timeout(5) { Process.wait(server) } -rescue Timeout::Error -end - -100.times do - begin - TCPSocket.new("127.0.0.1", port).close - break - rescue Errno::ECONNREFUSED - sleep 0.01 - end -end - -tests = ARGV.empty? ? Dir["#{root}/typesinfo.*"].sort : ARGV.map { |t| File.expand_path(t, root) } -total = ok = 0 -tests.each do |dir| - next unless File.directory?(dir) - total += 1 - file = File.join(dir, "test.go.in") - cursor = Dir[File.join(dir, "cursor.*")].first.split(".").last.to_i - source = File.binread(file) - cursor += source.byteslice(0, cursor).count("\n") if source.include?("\r\n") - expected = File.read(File.join(dir, "out.expected")) - out, status = Open3.capture2(binary, "-sock", "tcp", "-addr", addr, - "-in", file, "liteide_typesinfo", file, cursor.to_s) - out = "" unless status.success? - out = out.tr("\\", "/") - out = out.gsub(File.expand_path(file).tr("\\", "/"), "FILE") - goroot = ENV["GOROOT"] || `go env GOROOT`.strip - out = out.gsub(goroot, "GOROOT") - out = out.gsub(%r{.*/go/(?:\d+\.)+\d+/(?:[^/]+/)?src/}, "GOROOT/src/") - out = out.gsub(%r{.*/go\d+(?:\.\d+)+/(?:[^/]+/)?src/}, "GOROOT/src/") - out = out.gsub(%r{GOROOT/src/([^:]+):\d+:\d+}, 'GOROOT/src/\\1:LINE:COLUMN') - if out == expected - puts "#{File.basename(dir)}: #{GRN}PASS!#{NC}" - ok += 1 - else - puts "#{File.basename(dir)}: #{RED}FAIL!#{NC}" - puts "Got:\n#{out}Expected:\n#{expected}" - end -end -puts "\nSummary (total: #{total})" -puts "#{GRN} PASS#{NC}: #{ok}" -puts "#{RED} FAIL#{NC}: #{total - ok}" -exit(total == ok ? 0 : 1) From c677fd57dfb9be37e34818a732c2c9d4dffd9954 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sun, 30 Aug 2026 09:23:07 +0800 Subject: [PATCH 11/11] update README for current Go support --- README.md | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 058b9ec5..5d9c3686 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,9 @@ _LiteIDE is a simple, open source, cross-platform Go IDE._ _Gocode is a golang code autocomplete support for LiteIDE._ -- support Go1.11 Go modules. -- support Go1.18 generics. +- support Go modules. +- support generics and current Go syntax. +- tested with Go 1.25, Go 1.26, and Go 1.27. ``` go install github.com/visualfc/gocode@latest @@ -52,15 +53,7 @@ Also watch the [demo screencast](http://nosmileface.ru/images/gocode-demo.swf). `export PATH=$PATH:$GOPATH/bin` - 2. Then you need to get the appropriate version of the gocode, for 6g/8g/5g compiler you can do this: - - `go get -u github.com/nsf/gocode` (-u flag for "update") - - Windows users should consider doing this instead: - - `go get -u -ldflags -H=windowsgui github.com/nsf/gocode` - - That way on the Windows OS gocode will be built as a GUI application and doing so solves hanging window issues with some of the editors. + 2. Install the latest gocode with `go install github.com/visualfc/gocode@latest`. 3. Next steps are editor specific. See below. @@ -231,6 +224,20 @@ Please, report bugs, feature suggestions and other rants to the [github issue tr ### Developing +#### Running tests + +The regression tests use the Go standard test runner. Build the test binary and run +the autocomplete and server-side type information tests from `_testing`: + +```sh +go build -o _testing/gocode . +cd _testing +go test -v +``` + +On Windows, build the binary as `_testing/gocode.exe` instead. The test fixtures +include version- and platform-specific expected output where required. + There is [Guide for IDE/editor plugin developers](docs/IDE_integration.md). If you have troubles, please, contact me and I will try to do my best answering your questions. You can contact me via email. Or for short question find me on IRC: #go-nuts @ freenode.