1. 场景再现

addr := viper.Get("redis.addr")
	password := viper.Get("redis.password")
	db := viper.Get("redis.db")
	RedisCache = redis.NewClient(&redis.Options{
		Addr:     addr, // Cannot use 'addr' (type any) as the type string
		Password: "",
		DB:       0,
	})

2. 原因分析

类型不正确

3. 解决办法

转成对应的类型即可

.(string)
.(int)
addr := viper.Get("redis.addr")
	password := viper.Get("redis.password")
	db := viper.Get("redis.db")
	RedisCache = redis.NewClient(&redis.Options{
		Addr:     addr.(string),
		Password: password.(string),
		DB:       db.(int),
	})