GO語言"path"包中"Base"函數的用法及代碼示例。
用法:
func Base(path string) string
Base 返回路徑的最後一個元素。在提取最後一個元素之前刪除尾部斜杠。如果路徑為空,Base 返回"."。如果路徑完全由斜杠組成,則 Base 返回 "/"。
例子:
package main
import (
"fmt"
"path"
)
func main() {
fmt.Println(path.Base("/a/b"))
fmt.Println(path.Base("/"))
fmt.Println(path.Base(""))
}
輸出:
b / .
相關用法
- GO Buffer.Bytes用法及代碼示例
- GO Buffer.Read用法及代碼示例
- GO B.RunParallel用法及代碼示例
- GO Buffer.Len用法及代碼示例
- GO Buffer用法及代碼示例
- GO Buffer.Next用法及代碼示例
- GO Buffer.ReadByte用法及代碼示例
- GO B.ReportMetric用法及代碼示例
- GO Buffer.Cap用法及代碼示例
- GO Builder用法及代碼示例
- GO ByteOrder用法及代碼示例
- GO Buffer.Grow用法及代碼示例
- GO BinaryOp用法及代碼示例
- GO PutUvarint用法及代碼示例
- GO Scanner.Scan用法及代碼示例
- GO LeadingZeros32用法及代碼示例
- GO NewFromFiles用法及代碼示例
- GO Regexp.FindString用法及代碼示例
- GO Time.Sub用法及代碼示例
- GO Regexp.FindAllIndex用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Base。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。