如何在Revel上使用基于 redis 的会话?
我找到了这个要点,但不知道如何使用它..
编辑#1:
我的环境变量
GOROOT --> /usr/lib/go
GOPATH --> /home/asd/Dropbox/go
我做了什么:
mkdir -p $GOPATH/src/myapp/app/libs/session
curl https://gist.githubusercontent.com/xthexder/9026678/raw/9e40fb56d8991de945a2064b6869bb7280b1305a/session.go \
> $GOPATH/src/myapp/app/libs/session/session.go
go get github.com/garyburd/redigo
go get github.com/robfig/revel
添加import "myapp/app/libs/session"
,init.go
并显示此错误:
Go Compilation Error
The Go code Dropbox/go/src/myapp/app/libs/session/session.go does not compile: undefined: Redis
In Dropbox/go/src/myapp/app/libs/session/session.go (around line 75)
70: panic("Session values may not have null bytes")
71: }
72: sessionValue += "\x00" + key + ":" + value + "\x00"
73: }
74:
75: redisConn := Redis.Get()
76: defer redisConn.Close()
77:
78: params := []interface{}{"session:" + sessionToken, sessionValue}
79: if expireAfterDuration != 0 {
控制台上的错误:
WARN 2014/06/11 20:11:15 build.go:132: Cannot determine git repository version: exit status 128
ERROR 2014/06/11 20:11:15 build.go:84: # myapp/app/libs/session
Dropbox/go/src/myapp/app/libs/session/session.go:75: undefined: Redis
Dropbox/go/src/myapp/app/libs/session/session.go:126: undefined: Redis
Dropbox/go/src/myapp/app/libs/session/session.go:129: not enough arguments in call to redis.String
Dropbox/go/src/myapp/app/libs/session/session.go:172: undefined: Redis
Dropbox/go/src/myapp/app/libs/session/session.go:175: not enough arguments in call to redis.Int