diff options
author | Runxi Yu <me@runxiyu.org> | 2025-01-13 14:12:37 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-01-13 14:12:37 +0800 |
commit | b626ea8beb4bc1eef134a990eb1a7361c1c126b1 (patch) | |
tree | e054c0b34b6d009e22487f73a7beb4e4e77c9bd2 | |
parent | Add color to logging functions (diff) | |
download | go-lindenii-common-b626ea8beb4bc1eef134a990eb1a7361c1c126b1.tar.gz go-lindenii-common-b626ea8beb4bc1eef134a990eb1a7361c1c126b1.tar.zst go-lindenii-common-b626ea8beb4bc1eef134a990eb1a7361c1c126b1.zip |
Reformat code
-rw-r--r-- | misc/open_file.go | 14 | ||||
-rw-r--r-- | scfg/writer.go | 4 |
2 files changed, 8 insertions, 10 deletions
diff --git a/misc/open_file.go b/misc/open_file.go index ec5d402..945d78b 100644 --- a/misc/open_file.go +++ b/misc/open_file.go @@ -1,20 +1,20 @@ package misc import ( - "os" "errors" + "os" + "path" "strings" "syscall" - "path" ) type Dir_t struct { - fd int + fd int name string } var ( - Err_illegal_filename = errors.New("illegal filename") + Err_illegal_filename = errors.New("illegal filename") Err_invalid_file_descriptor = errors.New("invalid file descriptor") ) @@ -29,9 +29,9 @@ func Open_file_at(dir Dir_t, filename string, flags int, perms os.FileMode) (*os // Open a file at or beneath the given directory. func Open_file_beneath(dir Dir_t, filename string, flags int, perms os.FileMode) (*os.File, error) { fd, err := Openat2(dir.fd, filename, &Open_how_t{ - Flags: uint64(flags)|syscall.O_CLOEXEC, - Mode: uint64(syscallMode(perms)), - Resolve: RESOLVE_BENEATH|RESOLVE_NO_SYMLINKS, + Flags: uint64(flags) | syscall.O_CLOEXEC, + Mode: uint64(syscallMode(perms)), + Resolve: RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS, }) if err != nil { return nil, err diff --git a/scfg/writer.go b/scfg/writer.go index 97148a3..dd3b166 100644 --- a/scfg/writer.go +++ b/scfg/writer.go @@ -6,9 +6,7 @@ import ( "strings" ) -var ( - errDirEmptyName = errors.New("scfg: directive with empty name") -) +var errDirEmptyName = errors.New("scfg: directive with empty name") // Write writes a parsed configuration to the provided io.Writer. func Write(w io.Writer, blk Block) error { |