天天看點

s.Engine.Assets undefined (type *blocks.Blocks has no field or method Assets)

s.Engine.Assets undefined (type *blocks.Blocks has no field or method Assets)

  • 在使用golang iris寫背景項目時,遇到以下錯誤資訊
    ..\pkg\mod\github.com\kataras\[email protected]\view\blocks.go:76:37: undefined: blocks.AssetFunc
    ..\pkg\mod\github.com\kataras\[email protected]\view\blocks.go:76:66: undefined: blocks.AssetNamesFunc
    ..\pkg\mod\github.com\kataras\[email protected]\view\blocks.go:77:10: s.Engine.Assets undefined (type *blocks.Blocks has no field or method Assets)
               
  • 解決方案
    • ctrl + shift + f 全局搜 “github.com/kataras/iris”
    • 将import 中的“github.com/kataras/iris”全部替換成“github.com/kataras/iris/v12”