Skip to content

Panic in ToInt64 Function in util package When Handling int32 and smaller integer Types #155

@ahossameldin

Description

@ahossameldin

Hi there!
While testing queries, I encountered a panic when passing an int32 value to a query that i found uses ToInt64 function. The function converts only uint64 and int64 types to int64. If an int, int32, or any other type is passed, the function panics with the message “not a number” so i wondered if it was intended to converts int64 and uint64 only.

func ToInt64(v interface{}) int64 {
	switch vType := v.(type) {
	case uint64:
		return int64(vType)
	case int64:
		return vType
	}
	panic("not a number")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions