douboshan1466 2019-02-09 10:40
浏览 37
已采纳

Golang包未定义[重复]

I'm trying to install a redistore back end for my Gorilla sessions but I keep getting undefined errors. Here is the documentation I did run go get on the packages but the package import error says that it is imported but not used.

error:

undefined: NewRediStore

code:

package main

import (
...
"github.com/gorilla/sessions"
"gopkg.in/boj/redistore.v1"
)

func main() {

    // Fetch new store.
    store, err := NewRediStore(10, "tcp", ":6379", "", []byte("secret-key"))
    if err != nil {
        panic(err)
    }
    defer store.Close()
    ...
}
</div>
  • 写回答

1条回答 默认 最新

  • douyun1546 2019-02-09 10:52
    关注

    You need to qualify imported identifiers by prepending them with the package name which you imported. e.g. packagename.Identifiername.

    Or use . in front of the import to redeclare the exported identifiers of the imported package in the importing file's file block, however keep in mind that this is not a recommended practice.

    import (
        . "gopkg.in/boj/redistore.v1"
    )
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 三分类机器学习模型可视化分析
  • ¥15 本地测试网站127.0.0.1 已拒绝连接,如何解决?(标签-ubuntu)
  • ¥50 Qt在release捕获异常并跟踪堆栈(有Demo,跑一下环境再回答)
  • ¥30 python,LLM 文本提炼
  • ¥15 关于将inet引入的相关问题
  • ¥15 关于一个倒计时的操作和显示设计
  • ¥15 提问STK的问题,哪位航天领域的同学会啊
  • ¥15 苹果系统的mac m1芯片的笔记本使用ce修改器使用不了
  • ¥15 单相逆变的电压电流双闭环中进行低通滤波PID算法改进
  • ¥15 关于#java#的问题,请各位专家解答!