RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
创新互联GoFrame教程:GoFramegfile-常用目录

常用目录

Pwd

成都创新互联公司是一家专注于做网站、网站建设与策划设计,屯留网站建设哪家好?成都创新互联公司做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:屯留等地区。屯留做网站价格咨询:028-86922220

  • 说明:获取当前工作路径。
  • 格式: 
func Pwd() string

  • 示例:
func ExamplePwd() {
	// Get absolute path of current working directory.
	fmt.Println(gfile.Pwd())

	// May Output:
	// xxx/gf/os/gfile
}

Home

  • 说明:获取运行用户的主目录
  • 格式: 
func Home(names ...string) (string, error) 

  • 示例:
func ExampleHome() {
	// user's home directory
	homePath, _ := gfile.Home()
	fmt.Println(homePath)

	// May Output:
	// C:\Users\hailaz
}

TempDir

  • 说明:获取拼接系统临时路径后的绝对地址。
  • 格式: 
func TempDir(names ...string) string

  • 示例:
func ExampleTempDir() {
	// init
	var (
		fileName = "gfile_example_basic_dir"
	)

	// fetch an absolute representation of path.
	path := gfile.TempDir(fileName)

	fmt.Println(path)

	// Output:
	// /tmp/gfile_example_basic_dir
}

SelfPath

  • 说明:获取当前运行程序的绝对路径。
  • 格式: 
func SelfPath() string 

  • 示例:
func ExampleSelfPath() {

	// Get absolute file path of current running process
	fmt.Println(gfile.SelfPath())

	// May Output:
	// xxx/___github_com_GOgf_gf_v2_os_gfile__ExampleSelfPath
}


分享文章:创新互联GoFrame教程:GoFramegfile-常用目录
标题来源:http://www.jxjierui.cn/article/djispsd.html