Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]github.com/kataras/iris/v12/sessions.GetInt64Default when gives uint value 6 then got 0 return #1395

Closed
lmq1117 opened this issue Nov 20, 2019 · 3 comments

Comments

@lmq1117
Copy link

lmq1117 commented Nov 20, 2019

Describe the bug
github.com/kataras/iris/v12/sessions.GetInt64Default gives uint value 6 and i got 0 return

To Reproduce
Steps to reproduce the behavior:

  1. github.com/kataras/iris/v12/sessions.GetInt64Default call
    github.com/kataras/iris/v12/sessions.GetInt64
    when the v value is uint 6 t then the func GetInt64Default return the defaultValue

Expected behavior

  1. github.com/kataras/iris/v12/sessions.GetInt64Default call
    github.com/kataras/iris/v12/sessions.GetInt64
    when the v value is uint 6 and the func GetInt64Default should return Int64 6 not the defaultValue given

Desktop (please complete the following information):

  • OS: [windows]
@kataras
Copy link
Owner

kataras commented Nov 20, 2019

@lmq1117 this is not a bug it is expected, if you want to get an uint X value you (should) use .GetUint64Default instead of GetInt64Default. See the GetUint64Default method, it only checks for uint8, uint16,uint32 and int.

However, the uint types will be added to GetInt64Default if that's useful for you.

@kataras kataras added this to the v12.0.2 milestone Nov 20, 2019
@lmq1117
Copy link
Author

lmq1117 commented Nov 21, 2019

Thanks Reply
sorry i didn't speak clearly what i mean

i mean that when i set uint value to session,then i did have method to get the uint value from session
its the code

package main
import (
	"fmt"
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/sessions"
)
func main() {
	sess := sessions.New(sessions.Config{
		Cookie: "sessioncookiename",
	})
	app := iris.New()
	app.Logger().SetLevel("debug")
	app.Get("/sess", func(ctx iris.Context) {
		session := sess.Start(ctx)
		var u uint
		u = 6
		session.Set("user_id", u)
		fmt.Println("================")
		fmt.Println(session.GetInt("user_id"))
		fmt.Println(session.GetIntDefault("user_id", 0))
		fmt.Println("================")
		fmt.Println(session.GetInt64("user_id"))
		fmt.Println(session.GetInt64Default("user_id", 0))
		//fmt.Println("================")
		//fmt.Println(session.GetUint("user_id"))
		//fmt.Println(session.GetUintDefault("user_id", 0))
	})
	app.Run(iris.Addr(":8080"))
}

when you run and visit http://localhost:8080/sess
the console will print

================
-1 not found: user_id as int
0
================
-1 not found: user_id as int64
0

how to get uint value from session?

@kataras
Copy link
Owner

kataras commented Nov 21, 2019

You are welcome @lmq1117, yes I got it, by yesterday this commit fixes the above. It will be available for you to update and use at 23 Nov. as v12.0.2.

github-actions bot pushed a commit to goproxies/github.com-kataras-iris that referenced this issue Jul 27, 2020
Former-commit-id: 7c77e2f08fdcb7a48a6aa92364ba3b8e431d8d69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants