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"