ioutil.WriteFile permissions not functioning properly?

811 views
Skip to first unread message

Max Friel

unread,
May 27, 2010, 7:34:23 PM5/27/10
to golang-nuts
Group,
I am sure I am missing something incredibly simple and stupid here,
but I can not get the ioutil.WriteFile to set the proper permissions
for the file its creating. I am trying to get read and write
permissions for all users. Here are the three attempts I made at
using the function along with the file they output...
ioutil.WriteFile("fs.log", bytes.NewBufferString(out).Bytes(),0666)
-rw-r--r-- 1 root root 77 2010-05-27 19:24 fs.log
ioutil.WriteFile("fs.log", bytes.NewBufferString(out).Bytes(),666)
--w---x--T 1 root root 74 2010-05-27 19:25 fs.log
ioutil.WriteFile("fs.log", bytes.NewBufferString(out).Bytes(),0677)
-rw-r-xr-x 1 root root 77 2010-05-27 19:26 fs.log

Any thoughts as to what the correct integer for permissions would be
as well as why it does appear to be working as I would expect, ie 0666
being read/write permissions for all users.

Rob 'Commander' Pike

unread,
May 27, 2010, 7:54:29 PM5/27/10
to Max Friel, golang-nuts

I bet your umask is 022. Look in your Unix's documentation regarding
umask. Cursing might be appropriate too.

-rob

Max Friel

unread,
May 27, 2010, 8:08:51 PM5/27/10
to golang-nuts
I knew I was missing something stupid, thanks a lot
Reply all
Reply to author
Forward
0 new messages