模型库
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

file.go 536 B

3 달 전
12345678910111213141516171819202122
  1. package zhios_order_relate_utils
  2. import (
  3. "os"
  4. "path"
  5. "strings"
  6. "time"
  7. )
  8. // 获取文件后缀
  9. func FileExt(fname string) string {
  10. return strings.ToLower(strings.TrimLeft(path.Ext(fname), "."))
  11. }
  12. func FilePutContents(fileName string, content string) {
  13. fd, _ := os.OpenFile("./tmp/"+fileName+".logs", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
  14. fd_time := time.Now().Format("2006-01-02 15:04:05")
  15. fd_content := strings.Join([]string{"[", fd_time, "] ", content, "\n"}, "")
  16. buf := []byte(fd_content)
  17. fd.Write(buf)
  18. fd.Close()
  19. }