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

Usage of int64 as return #129

Open
a31amit opened this issue Sep 13, 2021 · 2 comments
Open

Usage of int64 as return #129

a31amit opened this issue Sep 13, 2021 · 2 comments

Comments

@a31amit
Copy link

a31amit commented Sep 13, 2021

First, Thanks for this cool library!

Question / Problem Statment :

I was trying to use this library to get starting offset values of partitions inside disk image from partition.GetStart()

func (p *Partition) GetStart() int64 {
	_, lss := p.sectorSizes()
	return int64(p.Start) * int64(lss)
}

I am not sure if I fully understand this or identifying a potential problem here due to the return value is int64 which could have negative integer numbers. However when working with partitions, If I understand correctly, cannot have a negative starting point and the minimum starting point is 0 so should not this be the return of uint64?

PS: I am a newbie in golang world. I could have missed something to understand.

@deitch
Copy link
Collaborator

deitch commented Sep 14, 2021

You are correct, and if it were up to me, those would be uint64. However, most of the basic golang disk utilities work off of int64, e.g. see File.ReadtAt() or fs.FileInfo or any of dozens of others.

I believe those came because the underlying C calls use long for the most part, e.g. fseek. It just made sense to stick with what people have.

@a31amit
Copy link
Author

a31amit commented Sep 18, 2021

Make sense, thanks for explaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants