Files
nl-blogs/.trae/documents/Fix Compilation Error in RBAC Handler.md
2026-01-15 13:51:44 +08:00

858 B

Fix Compilation Error: Unused Import

The error handlers_rbac.go:8:2: "github.com/niangaodev/art-code/models" imported and not used indicates that the models package is imported in handlers_rbac.go but no functions or types from it are directly used in that file.

Analysis

  • In handlers_rbac.go, I defined a local struct UpdateRolePermissionsRequest instead of using a model from the models package.
  • The functions call repositories.GetPermissions and repositories.GetRoleByID, which return model types, but these are handled via the repositories package or local variables, so the models package qualifier itself isn't explicitly used in the code logic.

Solution Plan

  1. Modify server/handlers_rbac.go:
    • Remove the unused import "github.com/niangaodev/art-code/models".

This will resolve the compilation error.