Explorar o código

Support hidden files :)

Tone %!s(int64=3) %!d(string=hai) anos
pai
achega
5b49c5a913
Modificáronse 1 ficheiros con 9 adicións e 7 borrados
  1. 9 7
      cmd/serve.go

+ 9 - 7
cmd/serve.go

@@ -169,13 +169,15 @@ func serverHandler(w http.ResponseWriter, r *http.Request) {
 
 		// Establish list of files in the current directory
 		for _, f := range files {
-			templateVars.Files = append(templateVars.Files, fileItem{
-				Name:  f.Name(),
-				Size:  humanize.Bytes(uint64(f.Size())),
-				Date:  humanize.Time(f.ModTime()),
-				IsDir: f.IsDir(),
-				Path:  filepath.Join(cfp, filepath.Clean(f.Name())),
-			})
+			if !strings.HasPrefix(f.Name(), ".") {
+				templateVars.Files = append(templateVars.Files, fileItem{
+					Name:  f.Name(),
+					Size:  humanize.Bytes(uint64(f.Size())),
+					Date:  humanize.Time(f.ModTime()),
+					IsDir: f.IsDir(),
+					Path:  filepath.Join(cfp, filepath.Clean(f.Name())),
+				})
+			}
 		}
 
 		// Prepare the template