Os.Mkdir vs syscall.Mkdir, what is the difference in the Golang?

os.Mkdir and syscall.Mkdir both have the same Golang API

syscall.Mkdir :

 func Mkdir(path string, mode uint32) (err error) 

os.Mkdir :

 func Mkdir(name string, perm FileMode) error 

What is the difference between the two?

+5
source share
1 answer

The first one is a platform-specific direct system call, possibly faster / you can use all platform-specific bits (e.g. sticky bit on Unix / Linux)

The latter is a portable API that should work the same on every platform; note that the second argument is no longer an anonymous integer, but a limited type.

+4
source

All Articles