osutil.go 383 B

123456789101112131415161718
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package osutil
  5. import (
  6. "os"
  7. )
  8. // IsFile returns true if given path exists as a file (i.e. not a directory).
  9. func IsFile(path string) bool {
  10. f, e := os.Stat(path)
  11. if e != nil {
  12. return false
  13. }
  14. return !f.IsDir()
  15. }