The following column golang tutorial will introduce to you the method to solve the same type of problem caused by the vendor in golang, but the prompts are of different types. I hope it will be helpful to friends who need it. Helps!
Question:
In the project, I used my own secondary development framework based on the open source project gin. When registering the route An error message was prompted, as follows:
cannot use func literal (type func(*"github.com/dazhenghu/cms/vendor/github.com/gin-gonic/gin".Context)) as type "github.com/gin-gonic/gin".HandlerFunc in argument to indexInstace.Controller.Get
Analysis:
It can be seen from the prompt that although they are all of func(*Context) type (Note: The type of HandlerFunc is func(*Context), you can check it in the gin source code by yourself), but the packages of the two are different. Obviously, the former is the package under the vendor in my project. It prompts that the path of this package is inconsistent. It should be Different packages loaded by the project lead to
Solution:
By executing the add dependency command: govendor add github.com/dazhenghu/ginApp/controller, the framework developed by yourself will also First add it to the vendor for management, and then execute it again, this error will not be reported
For more related technical articles, please visit the go language tutorial column!
The above is the detailed content of Solve the problem of the same type caused by vendor in golang, but prompting different types. For more information, please follow other related articles on the PHP Chinese website!