touch.go 403 B

12345678910111213141516171819
  1. // Copyright 2025 BackendServerTemplate 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 fileutils
  5. import (
  6. "os"
  7. )
  8. func Touch(filePath string) error {
  9. // 尝试打开文件
  10. file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY, 0644)
  11. if err != nil {
  12. return err
  13. }
  14. _ = file.Close()
  15. return nil
  16. }