diff --git a/gopmod/classfile.go b/gopmod/classfile.go index 86043ca..da090dc 100644 --- a/gopmod/classfile.go +++ b/gopmod/classfile.go @@ -116,7 +116,7 @@ func (p *Module) importClassFrom(modVer module.Version, impcls func(c *Project)) if err != nil { return } - c := mod.Opt.Project + c := mod.Project() if c == nil { return ErrNotClassFileMod } diff --git a/modload/module.go b/modload/module.go index 742b4ce..765d2ca 100644 --- a/modload/module.go +++ b/modload/module.go @@ -193,6 +193,14 @@ func LoadFrom(gomod, gopmod string) (p Module, err error) { // ----------------------------------------------------------------------------- +func (p Module) Project() *modfile.Project { + return p.Opt.Project +} + +func hasGopExtended(opt *modfile.File) bool { + return opt.Project != nil || len(opt.Import) > 0 +} + // Save saves all changes of this module. func (p Module) Save() (err error) { if p.IsDefault() { @@ -209,7 +217,7 @@ func (p Module) Save() (err error) { return } - if opt := p.Opt; gopExtended(opt) { + if opt := p.Opt; hasGopExtended(opt) { data, err = opt.Format() if err != nil { return @@ -219,10 +227,6 @@ func (p Module) Save() (err error) { return } -func gopExtended(opt *modfile.File) bool { - return opt.Project != nil || len(opt.Import) > 0 -} - /* const ( gopMod = "github.com/goplus/gop"