sessions
sessions copied to clipboard
Test code error
In the Test_SessionsDeleteValue
m.Get("/show", func(session Session) string {
if session.Get("hello") == "world" {
t.Error("Session value deleting failed")
}
return "OK"
})
Get("hello") return interface of hello and it would never equals to string "world"。
sorry for this post i tried the code package main
import (
"fmt"
)
func main() {
var a interface{}
a = "haha"
fmt.Println(a=="haha")
}
it works ok,but how can a interface{} equals to a string?
http://golang.org/ref/spec#Comparison_operators
In any comparison, the first operand must be assignable to the type of the second operand, or vice versa.
A value x of non-interface type X and a value t of interface type T are comparable when values of type X are comparable and X implements T. They are equal if t's dynamic type is identical to X and t's > dynamic value is equal to x.
http://golang.org/ref/spec#Types
Variables of interface type also have a distinct dynamic type, which is the actual type of the value stored in the variable at run time.