44 "bufio"
55 "errors"
66 "fmt"
7- "io/ioutil "
7+ "io"
88 "os"
99 "path/filepath"
1010 "sort"
@@ -17,8 +17,8 @@ import (
1717
1818type globFn = func (ignorer ignoreFn , args []string ) ([]FileContext , error )
1919
20- //LATER: regex-based globber
21- //LATER: glob with https://github.com/gobwas/glob
20+ // LATER: regex-based globber
21+ // LATER: glob with https://github.com/gobwas/glob
2222var globFunctions = map [string ]globFn {
2323 "" : doublestarExpander ,
2424 "doublestar" : doublestarExpander ,
@@ -39,7 +39,7 @@ func (g *Globber) String() string {
3939func (g * Globber ) Set (newValue string ) error {
4040
4141 if globFunctions [newValue ] == nil {
42- return fmt .Errorf ("Invalid glob algorithm '%s'" , newValue )
42+ return fmt .Errorf ("invalid glob algorithm '%s'" , newValue )
4343 }
4444 g .value = newValue
4545 return nil
@@ -72,7 +72,7 @@ func doublestarExpander(ignorer ignoreFn, args []string) ([]FileContext, error)
7272 fsys := os .DirFS (basepath )
7373 argfiles , dsErr := doublestar .Glob (fsys , pattern )
7474 if dsErr != nil {
75- return nil , fmt .Errorf ("Unable to expand %s at %s (doublestarExpander %w)" , pattern , basepath , dsErr )
75+ return nil , fmt .Errorf ("unable to expand %s at %s (doublestarExpander %w)" , pattern , basepath , dsErr )
7676 }
7777 for _ , argfile := range argfiles {
7878
@@ -86,7 +86,7 @@ func doublestarExpander(ignorer ignoreFn, args []string) ([]FileContext, error)
8686 }
8787 }
8888
89- if ignorer (argfile ) == true {
89+ if ignorer (argfile ) {
9090 continue
9191 }
9292
@@ -98,7 +98,7 @@ func doublestarExpander(ignorer ignoreFn, args []string) ([]FileContext, error)
9898
9999 fi , statErr := fc .Stat ()
100100 if statErr != nil {
101- return nil , fmt .Errorf ("Unable to stat %s (doublestarExpander, %w)" , arg , statErr )
101+ return nil , fmt .Errorf ("unable to stat %s (doublestarExpander, %w)" , arg , statErr )
102102 }
103103
104104 if fi .IsDir () {
@@ -121,7 +121,7 @@ func noExpander(ignorer ignoreFn, args []string) ([]FileContext, error) {
121121
122122 for _ , arg := range args {
123123
124- if ignorer (arg ) == true {
124+ if ignorer (arg ) {
125125 continue
126126 }
127127
@@ -131,7 +131,7 @@ func noExpander(ignorer ignoreFn, args []string) ([]FileContext, error) {
131131
132132 fi , statErr := fc .Stat ()
133133 if statErr != nil {
134- return nil , fmt .Errorf ("Unable to stat %s (noExpander, %w)" , arg , statErr )
134+ return nil , fmt .Errorf ("unable to stat %s (noExpander, %w)" , arg , statErr )
135135 }
136136 if fi .IsDir () {
137137 //LATER: or recurse?
@@ -152,7 +152,7 @@ func golangExpander(ignorer ignoreFn, args []string) ([]FileContext, error) {
152152 for _ , arg := range args {
153153 argfiles , globErr := filepath .Glob (homedirExpand (arg ))
154154 if globErr != nil {
155- return nil , fmt .Errorf ("Unable to glob %s (golangExpander, %w)" , arg , globErr )
155+ return nil , fmt .Errorf ("unable to glob %s (golangExpander, %w)" , arg , globErr )
156156 }
157157 for _ , argfile := range argfiles {
158158
@@ -166,7 +166,7 @@ func golangExpander(ignorer ignoreFn, args []string) ([]FileContext, error) {
166166 }
167167 }
168168
169- if ignorer (argfile ) == true {
169+ if ignorer (argfile ) {
170170 continue
171171 }
172172
@@ -210,9 +210,9 @@ func MakeFileCommand(checkFn func(*FileContext)) func(cmd *cobra.Command, args [
210210 if len (args ) == 1 && args [0 ] == "-" {
211211 useGlobber = false
212212 if isatty .IsTerminal (os .Stdin .Fd ()) {
213- return errors .New ("Attempt to read stdin from terminal" )
213+ return errors .New ("attempt to read stdin from terminal" )
214214 }
215- data , stdinReadErr := ioutil .ReadAll (os .Stdin ) //LATER: does this work on Windows w/binary files
215+ data , stdinReadErr := io .ReadAll (os .Stdin ) //LATER: does this work on Windows w/binary files
216216 if stdinReadErr != nil {
217217 return fmt .Errorf ("unable to read stdin: %w" , stdinReadErr )
218218 }
@@ -222,7 +222,7 @@ func MakeFileCommand(checkFn func(*FileContext)) func(cmd *cobra.Command, args [
222222 })
223223 } else if len (args ) == 1 && args [0 ] == "@-" {
224224 if isatty .IsTerminal (os .Stdin .Fd ()) {
225- return errors .New ("Attempt to read stdin from terminal" )
225+ return errors .New ("attempt to read stdin from terminal" )
226226 }
227227 scanner := bufio .NewScanner (os .Stdin )
228228 args = args [:0 ]
@@ -241,7 +241,7 @@ func MakeFileCommand(checkFn func(*FileContext)) func(cmd *cobra.Command, args [
241241 fcs , _ = globFunctions [globber .String ()](ignorer , args )
242242 }
243243 if len (fcs ) == 0 {
244- return fmt .Errorf ("No files to lint" )
244+ return fmt .Errorf ("no files to lint" )
245245 }
246246 if Debug {
247247 fmt .Fprintf (os .Stderr , "DEBUG: %d files after arg expansion\n " , len (fcs ))
0 commit comments