标签:
package main import ( "fmt" "path" "strings" ) func main() { fullFilename := "/Users/itfanr/Documents/test.txt" fmt.Println("fullFilename =", fullFilename) var filenameWithSuffix string filenameWithSuffix = path.Base(fullFilename) fmt.Println("filenameWithSuffix =", filenameWithSuffix) var fileSuffix string fileSuffix = path.Ext(filenameWithSuffix) fmt.Println("fileSuffix =", fileSuffix) var filenameOnly string filenameOnly = strings.TrimSuffix(filenameWithSuffix, fileSuffix) fmt.Println("filenameOnly =", filenameOnly) }
标签:
原文地址:http://my.oschina.net/itfanr/blog/373983