beego / beedoc

An open source project for beego documentation.
http://beego.me/docs
687 stars 917 forks source link

导入captcha时报错 #905

Open clingfei opened 3 years ago

clingfei commented 3 years ago

import( "crypto/md5" "fmt" "github.com/beego/beego/v2/client/orm" "github.com/beego/beego/v2/core/validation" beego "github.com/beego/beego/v2/server/web" "log" "github.com/astaxie/beego/cache" captcha2 "github.com/astaxie/beego/utils/captcha" ) func init() { // use beego cache system store the captcha data store := cache.NewMemoryCache() cpt = captcha2.NewWithFilter("/captcha/", store) }

会出现以下错误: ./Netdisk flag redefined: graceful panic: ./Netdisk flag redefined: graceful

goroutine 1 [running]: flag.(*FlagSet).Var(0xc000172660, 0xee0f40, 0x14d5188, 0xdaa5ef, 0x8, 0xdc1691, 0x21) /usr/lib/go-1.13/src/flag/flag.go:848 +0x4ae flag.BoolVar(...) /usr/lib/go-1.13/src/flag/flag.go:627

似乎是因为在flag.go和grace.go中重复定义了flag变量,但这两个变量是依赖包中所定义的,请问应当如何解决?

flycash commented 3 years ago

你不能使用"github.com/astaxie/beego/cache"。你应该用"github.com/beego/beego/server/web/filter/cacha"。大概是在这个位置。 你这里是v1.x和v2.x混用,会有很多问题。我建议你直接删掉github.com/astaxie/beego依赖