1. const (
    2. O_RDONLY int = syscall.O_RDONLY // 只读模式打开文件
    3. O_WRONLY int = syscall.O_WRONLY // 只写模式打开文件
    4. O_RDWR int = syscall.O_RDWR // 读写模式打开文件
    5. O_APPEND int = syscall.O_APPEND // 写操作时将数据附加到文件尾部
    6. O_CREATE int = syscall.O_CREAT // 如果不存在将创建一个新文件
    7. O_EXCL int = syscall.O_EXCL // 和O_CREATE配合使用,文件必须不存在
    8. O_SYNC int = syscall.O_SYNC // 打开文件用于同步I/O
    9. O_TRUNC int = syscall.O_TRUNC // 如果可能,打开时清空文件
    10. )
    1. const (
    2. // Exactly one of O_RDONLY, O_WRONLY, or O_RDWR must be specified.
    3. O_RDONLY int = syscall.O_RDONLY // open the file read-only.
    4. O_WRONLY int = syscall.O_WRONLY // open the file write-only.
    5. O_RDWR int = syscall.O_RDWR // open the file read-write.
    6. // The remaining values may be or'ed in to control behavior.
    7. O_APPEND int = syscall.O_APPEND // append data to the file when writing.
    8. O_CREATE int = syscall.O_CREAT // create a new file if none exists.
    9. O_EXCL int = syscall.O_EXCL // used with O_CREATE, file must not exist.
    10. O_SYNC int = syscall.O_SYNC // open for synchronous I/O.
    11. O_TRUNC int = syscall.O_TRUNC // truncate regular writable file when opened.
    12. )