#[Solved] How to open a file

1 messages · Page 1 of 1 (latest)

craggy moat
#

I'm trying to use os.open to create or open a read & write log into which I append to. Seems like I can't get the permission right.

This is my current version

fd, err := os.open(
    DEBUG_FILE,
    os.O_RDWR | os.O_CREATE | os.O_APPEND | os.S_IRUSR | os.S_IWUSR,
)

I was expecting this to return rw-r--r-- as permission. Instead I get r-x--x---

slate linden
#

Permissions go in the third argument

craggy moat
#

Ah! that should have been obvious. For anyone who cares in the future:

fd, err := os.open(
  DEBUG_FILE,
  os.O_RDWR | os.O_CREATE | os.O_APPEND,
  os.S_IRUSR | os.S_IWUSR | os.S_IRGRP | os.S_IROTH,
)
#

[Solved] How to open a file