alexedwards / scs

HTTP Session Management for Go
MIT License
2.13k stars 166 forks source link

error when use redis store #88

Closed chonlatee closed 4 years ago

chonlatee commented 4 years ago

build command-line-arguments: cannot load github.com/alexedwards/scs/v2/redisstore: module github.com/alexedwards/scs/v2@latest found (v2.3.0), but does not contain package github.com/alexedwards/scs/v2/redisstore

I try to use redisstore but I don't know why my go mod still uses v2.3.0.

chonlatee commented 4 years ago

in my pkg. it looks like v2.3.0 doesn't have redisstore.

alexedwards commented 4 years ago

Hi,

I think i might be because you need to import github.com/alexedwards/scs/redisstore not github.com/alexedwards/scs/v2/redisstore.

Can you run the basic example code in https://github.com/alexedwards/scs/tree/master/redisstore?

adnaan commented 4 years ago

Hi @alexedwards I have the same issue. The example code you have linked is not runnable:

cannot use redisstore.New(redisPool) (type *redisstore.RedisStore) as type scs.Store in assignment:
    *redisstore.RedisStore does not implement scs.Store (missing Commit method)

It seems v2/ doesn't export redisstore while the old version doesn't have the latest redisstore implementaion.

alexedwards commented 4 years ago

Hi,

I can't replicate this problem using Go 1.14. I've even tried completely purging my modcache in case there was something unexpected in my local cache that was causing it to work.

These are the following steps I took (the gist contains the example code from the link above):

$ mkdir test
$ cd test
$ wget https://gist.githubusercontent.com/alexedwards/29df406a09f9a9e8af98fec959707733/raw/1b4021fe3cf8263e6a111974da8fc60263f10f9f/main.go
$ go mod init test
$ go clean -modcache
$ go run .
go: finding module for package github.com/alexedwards/scs/redisstore
go: finding module for package github.com/alexedwards/scs/v2
go: finding module for package github.com/gomodule/redigo/redis
go: downloading github.com/gomodule/redigo v1.8.1
go: downloading github.com/alexedwards/scs/v2 v2.3.1
go: downloading github.com/alexedwards/scs/redisstore v0.0.0-20200503134757-95908882a5b1
go: downloading github.com/gomodule/redigo/redis v0.0.0-do-not-use
go: downloading github.com/alexedwards/scs v1.4.1
go: found github.com/alexedwards/scs/redisstore in github.com/alexedwards/scs/redisstore v0.0.0-20200503134757-95908882a5b1
go: found github.com/alexedwards/scs/v2 in github.com/alexedwards/scs/v2 v2.3.1
go: found github.com/gomodule/redigo/redis in github.com/gomodule/redigo v1.8.1
2020/05/23 06:34:32 starting server...

Can you run those commands on your machine and post the output? And also post your go env output?

adnaan commented 4 years ago

I tried these steps with go1.14. They work.

I also ran go clean -modcache in my project and it worked this time.

This time around go.mod has

github.com/alexedwards/scs/redisstore v0.0.0-20200503134757-95908882a5b1

instead of

github.com/alexedwards/scs/redisstore v1.4.1

which was picked by go.mod, before I ran go clean -modcache.

I can't explain it. Thank you for your help and sorry for the noise.