From f830ca367358239279c1134530f7a98c0558cdba Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 10 Aug 2026 12:01:52 +0800 Subject: [PATCH 1/5] modfile,xgomod: support AutoLambdas --- modfile/rule.go | 11 +++++++++-- xgomod/classfile.go | 13 +++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modfile/rule.go b/modfile/rule.go index ff3694f..9cc6897 100644 --- a/modfile/rule.go +++ b/modfile/rule.go @@ -91,8 +91,15 @@ type Project struct { PkgPaths []string // package paths of classfile and optional inline-imported packages. Import []*Import // auto-imported packages Pack *Pack // pack directive (at most one per project) - Flat bool // if true, all matching files are fragments of the project class (no work classfiles) - Syntax *Line + + // AutoLambdas maps command => number of parameters before auto lambda. + // See https://github.com/goplus/xgo/issues/2828. + AutoLambdas map[string]int + + // if Flat is true, all matching files are fragments of the project class (no work classfiles). + Flat bool + + Syntax *Line } // IsProj checks if a (ext, fname) pair is a project file or not. diff --git a/xgomod/classfile.go b/xgomod/classfile.go index 438d6f2..149cd78 100644 --- a/xgomod/classfile.go +++ b/xgomod/classfile.go @@ -59,6 +59,8 @@ func IsNotFound(err error) bool { // ClassKind checks a fname is a known classfile or not. // If it is, then it checks the fname is a project file or not. +// +// Deprecated: use ClassInfo instead. func (p *Module) ClassKind(fname string) (isProj, ok bool) { ext := modfile.ClassExt(fname) if c, ok := p.projs[ext]; ok { @@ -67,6 +69,17 @@ func (p *Module) ClassKind(fname string) (isProj, ok bool) { return } +// ClassInfo checks a fname is a known classfile or not. +// If it is, it returns the auto-lambda map, whether it is a project file, and true. +// See https://github.com/goplus/xgo/issues/2828 to learn about auto lambda. +func (p *Module) ClassInfo(fname string) (autoLambdas map[string]int, isProj, ok bool) { + ext := modfile.ClassExt(fname) + if c, ok := p.projs[ext]; ok { + return c.AutoLambdas, c.IsProj(ext, fname), true + } + return +} + // IsClass checks ext is a known classfile or not. func (p *Module) IsClass(ext string) (ok bool) { _, ok = p.projs[ext] From d0397ea56aec0c4d38f0f9252bdbd358f9fbfb1b Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 10 Aug 2026 12:05:24 +0800 Subject: [PATCH 2/5] xgomod: test ClassInfo --- xgomod/classfile.go | 5 +---- xgomod/xgomod_test.go | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/xgomod/classfile.go b/xgomod/classfile.go index 149cd78..4d6f0f0 100644 --- a/xgomod/classfile.go +++ b/xgomod/classfile.go @@ -62,10 +62,7 @@ func IsNotFound(err error) bool { // // Deprecated: use ClassInfo instead. func (p *Module) ClassKind(fname string) (isProj, ok bool) { - ext := modfile.ClassExt(fname) - if c, ok := p.projs[ext]; ok { - return c.IsProj(ext, fname), true - } + _, isProj, ok = p.ClassInfo(fname) return } diff --git a/xgomod/xgomod_test.go b/xgomod/xgomod_test.go index 897cea6..ba54aa8 100644 --- a/xgomod/xgomod_test.go +++ b/xgomod/xgomod_test.go @@ -150,7 +150,7 @@ func TestClassfile2(t *testing.T) { if err := mod.ImportClasses(func(c *Project) {}); err != nil { t.Fatal("mod.ImportClasses:", err) } - if isProj, ok := mod.ClassKind("foo_yap.gox"); !ok || !isProj { + if _, isProj, ok := mod.ClassInfo("foo_yap.gox"); !ok || !isProj { t.Fatal("mod.ClassKind foo_yap.gox:", isProj, ok) } if _, ok := mod.ClassKind("foo.gox"); ok { From f3b32a50ed1fe5f46d5708704e60dc2b82255814 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 10 Aug 2026 12:07:25 +0800 Subject: [PATCH 3/5] README: rm Report Card --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6f660ad..e6e41d2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ mod - Module support for Go/XGo ===== [![Build Status](https://github.com/goplus/mod/actions/workflows/go.yml/badge.svg)](https://github.com/goplus/mod/actions/workflows/go.yml) -[![Go Report Card](https://goreportcard.com/badge/github.com/goplus/mod)](https://goreportcard.com/report/github.com/goplus/mod) [![GitHub release](https://img.shields.io/github/v/tag/goplus/mod.svg?label=release)](https://github.com/goplus/mod/releases) [![Coverage Status](https://codecov.io/gh/goplus/mod/branch/main/graph/badge.svg)](https://codecov.io/gh/goplus/mod) [![GoDoc](https://pkg.go.dev/badge/github.com/goplus/mod.svg)](https://pkg.go.dev/github.com/goplus/mod) From 6a951f69167582f1ff418c636342be17ec62eca2 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 10 Aug 2026 12:11:45 +0800 Subject: [PATCH 4/5] ci: codecov.yml --- .github/codecov.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/codecov.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..6e1dfdf --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,3 @@ +coverage: + ignore: + - "modfetch" From f85904c125b18d64685b6f8dd4db23264e8769a6 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 10 Aug 2026 12:13:25 +0800 Subject: [PATCH 5/5] xgomod: test ClassInfo msg --- xgomod/xgomod_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xgomod/xgomod_test.go b/xgomod/xgomod_test.go index ba54aa8..d6e20e5 100644 --- a/xgomod/xgomod_test.go +++ b/xgomod/xgomod_test.go @@ -151,7 +151,7 @@ func TestClassfile2(t *testing.T) { t.Fatal("mod.ImportClasses:", err) } if _, isProj, ok := mod.ClassInfo("foo_yap.gox"); !ok || !isProj { - t.Fatal("mod.ClassKind foo_yap.gox:", isProj, ok) + t.Fatal("mod.ClassInfo foo_yap.gox:", isProj, ok) } if _, ok := mod.ClassKind("foo.gox"); ok { t.Fatal("mod.ClassKind foo.gox: ok?")