build_date_data.go 773 B

12345678910111213141516171819202122232425
  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 builddate
  5. import (
  6. "fmt"
  7. "github.com/SongZihuan/BackendServerTemplate/tool/generate/basefile"
  8. "github.com/SongZihuan/BackendServerTemplate/tool/utils/fileutils"
  9. "log"
  10. "time"
  11. )
  12. var buildTime = time.Now()
  13. func WriteBuildDateData() error {
  14. val := fmt.Sprint(buildTime.Unix())
  15. log.Printf("generate: write build data: %s UTC (timestaamp: %s)\n", buildTime.UTC().Format(time.DateTime), val)
  16. defer log.Println("generate: write build data finish")
  17. log.Printf("generate: write %s to file %s\n", val, basefile.FileBuildDateTxt)
  18. return fileutils.Write(basefile.FileBuildDateTxt, val)
  19. }