make linters happy

fix typos, less short and more idomatic variable names, package comments, etc.
This commit is contained in:
Lilian Jónsdóttir 2024-07-30 11:43:54 -07:00
parent 50e8c992d1
commit 9b87c02744
12 changed files with 259 additions and 247 deletions

View file

@ -1,3 +1,4 @@
// Package filemode does things io/fs doesn't do
package filemode
import (
@ -7,19 +8,21 @@ import (
// Parse parses a string of 3 or 4 numbers as a *NIX filesystem permission.
//
// "0777" or "777" -> fs.FileMode(0777)
// "0777" or "777" -> fs.FileMode(0777)
//
// "0644" or "644" -> fs.FileMode(0644)
func Parse(in string) (fs.FileMode, error) {
if in == "" {
// "0644" or "644" -> fs.FileMode(0644)
func Parse(input string) (fs.FileMode, error) {
const simplemodelen = 3
if input == "" {
return fs.FileMode(0), nil
}
if len(in) == 3 {
in = "0" + in
if len(input) == simplemodelen {
input = "0" + input
}
md, e := strconv.ParseUint(in, 8, 64)
md, e := strconv.ParseUint(input, 8, 64)
if e != nil {
return 0, e
}
return fs.FileMode(md), nil
}