亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

directory search
archive archive/tar archive/zip bufio bufio(緩存) builtin builtin(內置包) bytes bytes(包字節(jié)) compress compress/bzip2(壓縮/bzip2) compress/flate(壓縮/flate) compress/gzip(壓縮/gzip) compress/lzw(壓縮/lzw) compress/zlib(壓縮/zlib) container container/heap(容器數(shù)據(jù)結構heap) container/list(容器數(shù)據(jù)結構list) container/ring(容器數(shù)據(jù)結構ring) context context(上下文) crypto crypto(加密) crypto/aes(加密/aes) crypto/cipher(加密/cipher) crypto/des(加密/des) crypto/dsa(加密/dsa) crypto/ecdsa(加密/ecdsa) crypto/elliptic(加密/elliptic) crypto/hmac(加密/hmac) crypto/md5(加密/md5) crypto/rand(加密/rand) crypto/rc4(加密/rc4) crypto/rsa(加密/rsa) crypto/sha1(加密/sha1) crypto/sha256(加密/sha256) crypto/sha512(加密/sha512) crypto/subtle(加密/subtle) crypto/tls(加密/tls) crypto/x509(加密/x509) crypto/x509/pkix(加密/x509/pkix) database database/sql(數(shù)據(jù)庫/sql) database/sql/driver(數(shù)據(jù)庫/sql/driver) debug debug/dwarf(調試/dwarf) debug/elf(調試/elf) debug/gosym(調試/gosym) debug/macho(調試/macho) debug/pe(調試/pe) debug/plan9obj(調試/plan9obj) encoding encoding(編碼) encoding/ascii85(編碼/ascii85) encoding/asn1(編碼/asn1) encoding/base32(編碼/base32) encoding/base64(編碼/base64) encoding/binary(編碼/binary) encoding/csv(編碼/csv) encoding/gob(編碼/gob) encoding/hex(編碼/hex) encoding/json(編碼/json) encoding/pem(編碼/pem) encoding/xml(編碼/xml) errors errors(錯誤) expvar expvar flag flag(命令行參數(shù)解析flag包) fmt fmt go go/ast(抽象語法樹) go/build go/constant(常量) go/doc(文檔) go/format(格式) go/importer go/parser go/printer go/scanner(掃描儀) go/token(令牌) go/types(類型) hash hash(散列) hash/adler32 hash/crc32 hash/crc64 hash/fnv html html html/template(模板) image image(圖像) image/color(顏色) image/color/palette(調色板) image/draw(繪圖) image/gif image/jpeg image/png index index/suffixarray io io io/ioutil log log log/syslog(日志系統(tǒng)) math math math/big math/big math/bits math/bits math/cmplx math/cmplx math/rand math/rand mime mime mime/multipart(多部分) mime/quotedprintable net net net/http net/http net/http/cgi net/http/cookiejar net/http/fcgi net/http/httptest net/http/httptrace net/http/httputil net/http/internal net/http/pprof net/mail net/mail net/rpc net/rpc net/rpc/jsonrpc net/smtp net/smtp net/textproto net/textproto net/url net/url os os os/exec os/signal os/user path path path/filepath(文件路徑) plugin plugin(插件) reflect reflect(反射) regexp regexp(正則表達式) regexp/syntax runtime runtime(運行時) runtime/debug(調試) runtime/internal/sys runtime/pprof runtime/race(競爭) runtime/trace(執(zhí)行追蹤器) sort sort(排序算法) strconv strconv(轉換) strings strings(字符串) sync sync(同步) sync/atomic(原子操作) syscall syscall(系統(tǒng)調用) testing testing(測試) testing/iotest testing/quick text text/scanner(掃描文本) text/tabwriter text/template(定義模板) text/template/parse time time(時間戳) unicode unicode unicode/utf16 unicode/utf8 unsafe unsafe
characters

  • import "path"

  • 概況

  • 索引

  • 例子

  • 子目錄

概況

Package 路徑實現(xiàn)用于操作斜線分隔路徑的實用程序例程。

路徑包只能用于以正斜杠分隔的路徑,例如 URL 中的路徑。此軟件包不處理帶有驅動器號或反斜杠的 Windows 路徑; 要操作操作系統(tǒng)路徑,請使用路徑/文件路徑包。

索引

  • 變量

  • func Base(path string) string

  • func Clean(path string) string

  • func Dir(path string) string

  • func Ext(path string) string

  • func IsAbs(path string) bool

  • func Join(elem ...string) string

  • func Match(pattern, name string) (matched bool, err error)

  • func Split(path string) (dir, file string)

例子

Base Clean Dir Ext IsAbs Join Split

包文件

match.go path.go

變量

ErrBadPattern 表示通配模式格式錯誤。

var ErrBadPattern = errors.New("syntax error in pattern")

func Base

func Base(path string) string

Base 返回路徑的最后一個元素。在提取最后一個元素之前刪除尾部斜杠。如果路徑為空,則 Base 返回“?!?。如果路徑完全由斜線組成,則 Base 返回“/”。

package mainimport ("fmt""path")func main() {
	fmt.Println(path.Base("/a/b"))
	fmt.Println(path.Base("/"))
	fmt.Println(path.Base(""))}

func Clean

func Clean(path string) string

Clean 通過純詞法處理返回等價于路徑的最短路徑名。它反復應用以下規(guī)則,直到不能進行進一步的處理:

1. Replace multiple slashes with a single slash.2. Eliminate each . path name element (the current directory).3. Eliminate each inner .. path name element (the parent directory)
   along with the non-.. element that precedes it.4. Eliminate .. elements that begin a rooted path:
   that is, replace "/.." by "/" at the beginning of a path.

返回的路徑只有以“/”為根時才以斜杠結尾。

如果此進程的結果是空字符串,則 Clean 將返回字符串“?!薄?/p>

package mainimport ("fmt""path")func main() {
	paths := []string{"a/c","a//c","a/c/.","a/c/b/..","/../a/c","/../a/b/../././/c","",}for _, p := range paths {
		fmt.Printf("Clean(%q) = %q\n", p, path.Clean(p))}}

func Dir

func Dir(path string) string

Dir 返回路徑的最后一個元素,通常是路徑的目錄。在使用 Split 刪除最后一個元素之后,路徑被清理并刪除尾部的斜杠。如果路徑為空,則 Dir 返回“?!薄H绻窂酵耆尚本€和非斜線字節(jié)組成,則 Dir 會返回一個斜線。在任何其他情況下,返回的路徑不會以斜杠結尾。

package mainimport ("fmt""path")func main() {
	fmt.Println(path.Dir("/a/b/c"))
	fmt.Println(path.Dir("a/b/c"))
	fmt.Println(path.Dir("/"))
	fmt.Println(path.Dir(""))}

func Ext

func Ext(path string) string

Ext 返回 path 使用的文件擴展名。擴展名是從路徑的最后一個斜杠分隔元素中的最后一個點開始的后綴; 如果沒有點,它是空的。

package mainimport ("fmt""path")func main() {
	fmt.Println(path.Ext("/a/b/c/bar.css"))
	fmt.Println(path.Ext("/"))
	fmt.Println(path.Ext(""))}

func IsAbs

func IsAbs(path string) bool

IsAbs 報告路徑是否是絕對的。

package mainimport ("fmt""path")func main() {
	fmt.Println(path.IsAbs("/dev/null"))}

func Join

func Join(elem ...string) string

Join 將任意數(shù)量的路徑元素加入到單個路徑中,如有必要添加分隔斜線。結果是 Cleaned; 特別是,所有空串都被忽略。

package mainimport ("fmt""path")func main() {
	fmt.Println(path.Join("a", "b", "c"))
	fmt.Println(path.Join("a", "b/c"))
	fmt.Println(path.Join("a/b", "c"))
	fmt.Println(path.Join("", ""))
	fmt.Println(path.Join("a", ""))
	fmt.Println(path.Join("", "a"))}

func Match

func Match(pattern, name string) (matched bool, err error)

匹配報告名稱是否與 shell 文件名稱模式相匹配。模式語法是:

pattern:{ term }term:'*'         matches any sequence of non-/ characters'?'         matches any single non-/ character'[' [ '^' ] { character-range } ']'
	            character class (must be non-empty)
	c           matches character c (c != '*', '?', '\\', '[')'\\' c      matches character c

character-range:
	c           matches character c (c != '\\', '-', ']')'\\' c      matches character c
	lo '-' hi   matches character c for lo <= c <= hi

匹配需要匹配所有名稱的模式,而不僅僅是一個子字符串。當模式格式錯誤時,唯一可能返回的錯誤是 ErrBadPattern 。

func Split

func Split(path string) (dir, file string)

Split 在最后一個斜杠之后立即拆分路徑,將其分隔成一個目錄和文件名組件。如果路徑中沒有斜線,Split 將返回一個空的目錄并將文件設置為路徑。返回的值具有 path = dir + file 的屬性。

package mainimport ("fmt""path")func main() {
	fmt.Println(path.Split("static/myfile.css"))
	fmt.Println(path.Split("myfile.css"))
	fmt.Println(path.Split(""))}

子目錄

Name

Synopsis

Previous article: Next article: