Why does Go's (*osFile).Fd function return a uintptr rather than an int?

Viewed 35

Why does Go's (*os.File).Fd function return a uintptr rather than an int?

To call cgo with the file descriptor, is it sufficient to just do the following?

fd := int(my_file.Fd())
C.my_cgo_func(C.int(fd))

Or is there more that needs to be done to correctly translate from the uintptr to a file descriptor that can be used for C file operations?

0 Answers
Related