I was looking at the os package docs and saw this:
f, err := os.OpenFile("access.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
According to the docs the OpenFile
signature its
func OpenFile(name string, flag int, perm FileMode) (*File, error)
Why does this works passing os.O_APPEND|os.O_CREATE|os.O_WRONLY
as the second argument?
CodePudding user response:
The constants os.O_APPEND
, os.O_CREATE
, and os.O_WRONLY
are int
s, so this is taking the bitwise OR operation on them and combining them into a single int
.