现在最新的go-admin web 框架发布到2.0.8版本,根据官网的指南很快就能把程序跑起来,然后我发现它使用的依赖依然没有持续更新,大部分依赖都能自己慢慢升级到最新的版本,但是唯独这个sentinel-golang,从0.6.2升级到最新的1.0.4之后,原来的引用就报错了。

在文件:“common\middleware\sentinel.go”文件中,对sentinel-golang的引用是:

sentinelPlugin "github.com/alibaba/sentinel-golang/adapter/gin"

但是会报错找不到这个包。然后这搞半天,以为1.0以后不再支持gin,后面在wiki发现还是有对gin的支持

我们很高兴地宣布 Sentinel Go 1.0.0 已经发布!这是一个生产就绪的 GA 版本,具有多种容错和流量控制功能,包括速率限制、并发限制(信号量隔离)、节流、断路、系统自适应保护和“热点”流量整形。我们已经为Gin、go-micro、gRPC 和 dubbo-go 等常用框架提供了插件。我们还在云原生演进方面取得了进展,包括 Kubernetes CRD 数据源、基于 Sentinel 指标的 Kubernetes HPA 和服务网格插件。

这是当时他们的支持:https://github.com/sentinel-group/sentinel-go-adapters

但是呢,只活到1.0.2就被抛弃了。也没写后续怎么处理。

后面我就觉得不至于就不支持了吧。

然后去源码找,发现在pkg/adapters包下还有gin呀,说明还是有支持的

但是呢,用go get下载的依赖里面并没有pkg这个文件夹。很疑惑。

后面发现把import改一下:

sentinelPlugin "github.com/alibaba/sentinel-golang/pkg/adapters/gin"

注意是加了pkg,然后adapter变adapters

然后 go mod tidy,会自动下载依赖了

实测go-admin能够正常运行

PS:没有实际测试sentinel的功能是否正常

附上我在go1.7基础上升级的go-admin的依赖列表:

go.mod:

module go-admin

go 1.17

require (
	github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
	github.com/alibaba/sentinel-golang v1.0.4
	github.com/alibaba/sentinel-golang/pkg/adapters/gin v0.0.0-20220208080722-89ef54d62272
	github.com/aliyun/aliyun-oss-go-sdk v2.2.0+incompatible
	github.com/bitly/go-simplejson v0.5.0
	github.com/bytedance/go-tagexpr/v2 v2.9.2
	github.com/casbin/casbin/v2 v2.41.0
	github.com/gin-gonic/gin v1.7.7
	github.com/go-admin-team/go-admin-core v1.3.10
	github.com/go-admin-team/go-admin-core/sdk v1.3.10
	github.com/google/uuid v1.3.0
	github.com/mssola/user_agent v0.5.3
	github.com/opentracing/opentracing-go v1.2.0
	github.com/prometheus/client_golang v1.12.1
	github.com/robfig/cron/v3 v3.0.1
	github.com/shirou/gopsutil v3.21.11+incompatible
	github.com/spf13/cobra v1.3.0
	github.com/swaggo/gin-swagger v1.4.1
	github.com/swaggo/swag v1.7.9
	github.com/unrolled/secure v1.0.9
	golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2
	gorm.io/driver/mysql v1.2.3
	gorm.io/driver/postgres v1.2.3
	gorm.io/driver/sqlite v1.2.6
	gorm.io/gorm v1.22.5
)

require (
	github.com/BurntSushi/toml v0.3.1 // indirect
	github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
	github.com/KyleBanks/depth v1.2.1 // indirect
	github.com/PuerkitoBio/purell v1.1.1 // indirect
	github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
	github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
	github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
	github.com/beorn7/perks v1.0.1 // indirect
	github.com/bsm/redislock v0.5.0 // indirect
	github.com/cespare/xxhash/v2 v2.1.2 // indirect
	github.com/chanxuehong/rand v0.0.0-20201110082127-2f19a1bdd973 // indirect
	github.com/chanxuehong/wechat v0.0.0-20201110083048-0180211b69fd // indirect
	github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
	github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc // indirect
	github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
	github.com/fatih/color v1.13.0 // indirect
	github.com/fsnotify/fsnotify v1.5.1 // indirect
	github.com/ghodss/yaml v1.0.0 // indirect
	github.com/gin-contrib/sse v0.1.0 // indirect
	github.com/git-chglog/git-chglog v0.0.0-20190611050339-63a4e637021f // indirect
	github.com/go-admin-team/go-admin-core/plugins/logger/zap v0.0.0-20210610020726-2db73adb505d // indirect
	github.com/go-admin-team/gorm-adapter/v3 v3.2.1-0.20210902112335-4148cb356a24 // indirect
	github.com/go-ole/go-ole v1.2.6 // indirect
	github.com/go-openapi/jsonpointer v0.19.5 // indirect
	github.com/go-openapi/jsonreference v0.19.6 // indirect
	github.com/go-openapi/spec v0.20.4 // indirect
	github.com/go-openapi/swag v0.19.15 // indirect
	github.com/go-playground/locales v0.13.0 // indirect
	github.com/go-playground/universal-translator v0.17.0 // indirect
	github.com/go-playground/validator/v10 v10.4.1 // indirect
	github.com/go-redis/redis/v7 v7.4.0 // indirect
	github.com/go-sql-driver/mysql v1.6.0 // indirect
	github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
	github.com/golang/protobuf v1.5.2 // indirect
	github.com/golang/snappy v0.0.3 // indirect
	github.com/gorilla/websocket v1.4.2 // indirect
	github.com/henrylee2cn/ameda v1.4.10 // indirect
	github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 // indirect
	github.com/imdario/mergo v0.3.9 // indirect
	github.com/inconshreveable/mousetrap v1.0.0 // indirect
	github.com/jackc/chunkreader/v2 v2.0.1 // indirect
	github.com/jackc/pgconn v1.10.1 // indirect
	github.com/jackc/pgio v1.0.0 // indirect
	github.com/jackc/pgpassfile v1.0.0 // indirect
	github.com/jackc/pgproto3/v2 v2.2.0 // indirect
	github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
	github.com/jackc/pgtype v1.9.0 // indirect
	github.com/jackc/pgx/v4 v4.14.0 // indirect
	github.com/jinzhu/inflection v1.0.0 // indirect
	github.com/jinzhu/now v1.1.4 // indirect
	github.com/josharian/intern v1.0.0 // indirect
	github.com/json-iterator/go v1.1.12 // indirect
	github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
	github.com/leodido/go-urn v1.2.0 // indirect
	github.com/mailru/easyjson v0.7.6 // indirect
	github.com/mattn/go-colorable v0.1.12 // indirect
	github.com/mattn/go-isatty v0.0.14 // indirect
	github.com/mattn/go-sqlite3 v1.14.9 // indirect
	github.com/mattn/goveralls v0.0.2 // indirect
	github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
	github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
	github.com/modern-go/reflect2 v1.0.2 // indirect
	github.com/mojocn/base64Captcha v1.3.1 // indirect
	github.com/nsqio/go-nsq v1.0.8 // indirect
	github.com/nyaruka/phonenumbers v1.0.55 // indirect
	github.com/pkg/errors v0.9.1 // indirect
	github.com/prometheus/client_model v0.2.0 // indirect
	github.com/prometheus/common v0.32.1 // indirect
	github.com/prometheus/procfs v0.7.3 // indirect
	github.com/robinjoseph08/redisqueue/v2 v2.1.0 // indirect
	github.com/russross/blackfriday/v2 v2.1.0 // indirect
	github.com/shamsher31/goimgext v1.0.0 // indirect
	github.com/shirou/gopsutil/v3 v3.21.6 // indirect
	github.com/spf13/cast v1.4.1 // indirect
	github.com/spf13/pflag v1.0.5 // indirect
	github.com/tklauser/go-sysconf v0.3.6 // indirect
	github.com/tklauser/numcpus v0.2.2 // indirect
	github.com/tsuyoshiwada/go-gitcmd v0.0.0-20180205145712-5f1f5f9475df // indirect
	github.com/ugorji/go/codec v1.1.7 // indirect
	github.com/urfave/cli v1.22.1 // indirect
	github.com/yusufpapurcu/wmi v1.2.2 // indirect
	go.uber.org/atomic v1.7.0 // indirect
	go.uber.org/multierr v1.6.0 // indirect
	go.uber.org/zap v1.17.0 // indirect
	golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb // indirect
	golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
	golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
	golang.org/x/text v0.3.7 // indirect
	golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
	golang.org/x/tools v0.1.7 // indirect
	google.golang.org/protobuf v1.27.1 // indirect
	gopkg.in/AlecAivazis/survey.v1 v1.8.5 // indirect
	gopkg.in/kyokomi/emoji.v1 v1.5.1 // indirect
	gopkg.in/yaml.v2 v2.4.0 // indirect
	gorm.io/driver/sqlserver v1.0.4 // indirect
	gorm.io/plugin/dbresolver v1.1.0 // indirect
)