golang path/filepath 包

Golang · Fecmall · 于 5年前 发布 · 1622 次阅读
package config

import (
	"path/filepath"
	"string"
)
func main() {
	fileName = "/root/go/src/bitbucket.org/tixid/TixId_Middleware_Go/config.toml"
	splits := strings.Split(filepath.Base(fileName), ".")
	log.Info(fileName)
	log.Info(filepath.Base(fileName))
	log.Info(splits)
	log.Info(splits[0])
	log.Info(filepath.Base(splits[0]))
	log.Info(filepath.Dir(fileName))
}

输出:

INFO[0000] /root/go/src/bitbucket.org/tixid/TixId_Middleware_Go/config.toml  fields.time="2018-11-20T07:09:37Z" hostname=ima-ThinkPad-W540 source="config.go:19"
INFO[0000] config.toml                                   fields.time="2018-11-20T07:09:37Z" hostname=ima-ThinkPad-W540 source="config.go:20"
INFO[0000] [config toml]                                 fields.time="2018-11-20T07:09:37Z" hostname=ima-ThinkPad-W540 source="config.go:21"
INFO[0000] config                                        fields.time="2018-11-20T07:09:37Z" hostname=ima-ThinkPad-W540 source="config.go:23"
INFO[0000] config                                        fields.time="2018-11-20T07:09:37Z" hostname=ima-ThinkPad-W540 source="config.go:24"
INFO[0000] /root/go/src/bitbucket.org/tixid/TixId_Middleware_Go  fields.time="2018-11-20T07:09:37Z" hostname=ima-ThinkPad-W540 source="config.go:25"

共收到 0 条回复
没有找到数据。
添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics