您的位置:58编程 > go files GoFrame gfile-文件检索

go files GoFrame gfile-文件检索

2023-05-08 18:33 GoFrame教程

go files GoFrame gfile-文件检索

go files GoFrame gfile-文件检索

go files

文件检索

Search

  • 说明:在指定目录(默认包含当前目录、运行目录、主函数目录;不会递归子目录)中搜索文件并返回真实路径。
  • 格式: 

func Search(name string, prioritySearchPaths ...string) (realPath string, err error) 

  • 示例:

func ExampleSearch() {
	// init
	var (
		fileName = "gflie_example.txt"
		tempDir  = gfile.TempDir("gfile_example_search")
		tempFile = gfile.Join(tempDir, fileName)
	)

	// write contents
	gfile.PutContents(tempFile, "goframe example content")

	// search file
	realPath, _ := gfile.Search(fileName, tempDir)
	fmt.Println(gfile.Basename(realPath))

	// Output:
	// gflie_example.txt
}


阅读全文
以上是58编程为你收集整理的go files GoFrame gfile-文件检索全部内容。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
相关文章
© 2024 58编程 58biancheng.com 版权所有 联系我们
桂ICP备12005667号-32 Powered by CMS