You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xiaoqidun be86327699
feat(升级依赖): 升级依赖
9 months ago
.gitignore feat(初始项目): 初始项目 2 years ago
LICENSE Initial commit 2 years ago
README.md docs(更新文档): 更新文档 2 years ago
go.mod feat(升级依赖): 升级依赖 9 months ago
setft.go feat(初始项目): 初始项目 2 years ago
setft_test.go feat(初始项目): 初始项目 2 years ago
setft_windows.go feat(初始项目): 初始项目 2 years ago

README.md

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

setft

Golang SetFileTime修改文件的访问时间、创建时间、修改时间。

使用说明

package main

import (
	"github.com/xiaoqidun/setft"
	"log"
	"time"
)

func main() {
	// 时间字符格式
	layout := "2006-01-02 15:04:05"
	// 设置访问时间
	atime, _ := time.ParseInLocation(layout, "2021-01-01 00:00:00", time.Local)
	// 设置创建时间
	ctime, _ := time.ParseInLocation(layout, "2021-01-01 00:00:00", time.Local)
	// 设置修改时间
	mtime, _ := time.ParseInLocation(layout, "2021-01-01 00:00:00", time.Local)
	// 修改文件时间
	if err := setft.SetFileTime("setft_test.go", atime, ctime, mtime); err != nil {
		log.Println(err)
	}
}