flipped-aurora/gin-vue-admin · error

child plugin import cannot be blank or dot imported

Error message

child plugin import cannot be blank or dot imported

What it means

When injecting the child plugin import into the parent's plugin.go, the installer computes an import alias (from the spec name or the plugin name). Blank (`_`) and dot (`.`) imports are rejected because the parent's Register function must reference the child package by identifier to call its registration; blank/dot imports would make that reference impossible or ambiguous.

Source

Thrown at server/service/system/auto_code_plugin.go:600

	alias := "subPlugin_" + childPlugin
	imported := false
	for _, spec := range astFile.Imports {
		importPath, err := strconv.Unquote(spec.Path.Value)
		if err != nil {
			return err
		}
		if importPath != childImportPath {
			continue
		}
		imported = true
		if spec.Name == nil {
			alias = childPlugin
		} else {
			alias = spec.Name.Name
		}
	}
	if alias == "_" || alias == "." {
		return errors.New("child plugin import cannot be blank or dot imported")
	}
	if !imported {
		importSpec := &goast.ImportSpec{
			Name: goast.NewIdent(alias),
			Path: &goast.BasicLit{Kind: token.STRING, Value: strconv.Quote(childImportPath)},
		}
		if importDecl := firstImportDeclaration(astFile); importDecl == nil {
			astFile.Decls = append([]goast.Decl{
				&goast.GenDecl{Tok: token.IMPORT, Specs: []goast.Spec{importSpec}},
			}, astFile.Decls...)
		} else {
			importDecl.Specs = append(importDecl.Specs, importSpec)
		}
	}

	registerFunc := findPluginRegisterFunction(astFile)
	if registerFunc == nil {
		return errors.New("parent plugin does not implement Register")

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Edit the parent plugin.go to import the child package with a named alias (typically the child plugin name), not `_` or `.`.
  2. If the parent used init()-side-effect registration, add an explicit call to the child's Register function inside the parent's Register instead.
  3. Re-run the sub-plugin install after fixing the import so the installer can add/verify the registration call.

Example fix

// before (parent plugin.go)
import (
	_ "github.com/org/project/plugin/parent/subPlugin/child"
)
// after
import (
	child "github.com/org/project/plugin/parent/subPlugin/child"
)

func Register(group *gin.RouterGroup) {
	child.Register(group)
}
Defensive patterns

Strategy: validation

Validate before calling

// before install, scan parent plugin.go imports
if hasBlankOrDotImport(parentPluginGo, childImportPath) {
  return errors.New("replace blank/dot import of child plugin with a named import")
}

Try / catch

if err := installSubPlugin(parent, child); err != nil {
  if strings.Contains(err.Error(), "blank or dot imported") {
    log.Fatal("edit parent plugin.go: use a named import for the child package")
  }
  return err
}

Prevention

When it happens

Trigger: The parent plugin.go already imports the child package with alias `_` or `.` (e.g. someone relied on side-effect-only init registration), and the installer's alias resolution yields `_` or `.` for the child import path.

Common situations: Hand-edited parent plugin.go using `import _ ".../child"` for init-only registration; copied import style from another project; alias accidentally written as underscore when the child plugin name is empty or collides with an existing identifier.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/c340660117915299. Report an issue: GitHub.