This question already has an answer here:
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>
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"
)