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

directory search
archive archive/tar archive/zip bufio bufio(緩存) builtin builtin(內(nèi)置包) bytes bytes(包字節(jié)) compress compress/bzip2(壓縮/bzip2) compress/flate(壓縮/flate) compress/gzip(壓縮/gzip) compress/lzw(壓縮/lzw) compress/zlib(壓縮/zlib) container container/heap(容器數(shù)據(jù)結(jié)構(gòu)heap) container/list(容器數(shù)據(jù)結(jié)構(gòu)list) container/ring(容器數(shù)據(jù)結(jié)構(gòu)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(調(diào)試/dwarf) debug/elf(調(diào)試/elf) debug/gosym(調(diào)試/gosym) debug/macho(調(diào)試/macho) debug/pe(調(diào)試/pe) debug/plan9obj(調(diào)試/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(錯(cuò)誤) 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(調(diào)色板) 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(正則表達(dá)式) regexp/syntax runtime runtime(運(yùn)行時(shí)) runtime/debug(調(diào)試) runtime/internal/sys runtime/pprof runtime/race(競(jìng)爭) runtime/trace(執(zhí)行追蹤器) sort sort(排序算法) strconv strconv(轉(zhuǎn)換) strings strings(字符串) sync sync(同步) sync/atomic(原子操作) syscall syscall(系統(tǒng)調(diào)用) testing testing(測(cè)試) testing/iotest testing/quick text text/scanner(掃描文本) text/tabwriter text/template(定義模板) text/template/parse time time(時(shí)間戳) unicode unicode unicode/utf16 unicode/utf8 unsafe unsafe
characters

  • import "path/filepath"

  • 概述

  • 索引

  • 例子

概述

軟件包文件路徑以與目標(biāo)操作系統(tǒng)定義的文件路徑兼容的方式實(shí)現(xiàn)用于操作文件名路徑的實(shí)用程序例程。

filepath 包使用正斜杠或反斜杠,具體取決于操作系統(tǒng)。要處理不管操作系統(tǒng)如何都始終使用正斜杠的 URL,請(qǐng)參閱路徑包。

索引

  • 常量

  • Variables

  • func Abs(path string) (string, error)

  • func Base(path string) string

  • func Clean(path string) string

  • func Dir(path string) string

  • func EvalSymlinks(path string) (string, error)

  • func Ext(path string) string

  • func FromSlash(path string) string

  • func Glob(pattern string) (matches []string, err error)

  • func HasPrefix(p, prefix string) bool

  • func IsAbs(path string) bool

  • func Join(elem ...string) string

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

  • func Rel(basepath, targpath string) (string, error)

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

  • func SplitList(path string) []string

  • func ToSlash(path string) string

  • func VolumeName(path string) string

  • func Walk(root string, walkFn WalkFunc) error

  • type WalkFunc

例子

Join Rel Split SplitList

包文件

match.go path.go path_unix.go symlink.go symlink_unix.go

常量

const (
        Separator     = os.PathSeparator
        ListSeparator = os.PathListSeparator)

變量

ErrBadPattern 表示通配模式格式錯(cuò)誤。

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

SkipDir 被用作來自 WalkFuncs 的返回值,以指示呼叫中指定的目錄將被跳過。它不會(huì)被任何函數(shù)返回為錯(cuò)誤。

var SkipDir = errors.New("skip this directory")

func Abs

func Abs(path string) (string, error)

Abs 返回路徑的絕對(duì)表示。如果路徑不是絕對(duì)路徑,它將與當(dāng)前工作目錄連接,將其變?yōu)榻^對(duì)路徑。并不保證給定文件的絕對(duì)路徑名是唯一的。Abs 在結(jié)果上調(diào)用 Clean 。

func Base

func Base(path string) string

Base 返回路徑的最后一個(gè)元素。在提取最后一個(gè)元素之前,刪除了尾部路徑分隔符。如果路徑為空,則 Base 返回“。”。如果路徑完全由分隔符組成,則 Base 將返回一個(gè)分隔符。

func Clean

func Clean(path string) string

Clean 通過純?cè)~法處理返回等價(jià)于路徑的最短路徑名。它反復(fù)應(yīng)用以下規(guī)則,直到不能進(jìn)行進(jìn)一步的處理:

1. Replace multiple Separator elements with a single one.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,
   assuming Separator is '/'.

僅當(dāng)返回的路徑表示根目錄(例如 Unix 或C:\Windows 上的“/”)時(shí),才以斜線結(jié)尾。

最后,任何出現(xiàn)的斜杠被分隔符替換。

如果此進(jìn)程的結(jié)果是空字符串,則 Clean 將返回字符串“。”。

func Dir

func Dir(path string) string

Dir 返回路徑的最后一個(gè)元素,通常是路徑的目錄。刪除最后一個(gè)元素后,Dir 在路徑上調(diào)用 Clean 并刪除尾部斜線。如果路徑為空,則 Dir 返回“?!?。如果路徑完全由分隔符組成,則 Dir 返回一個(gè)分隔符。返回的路徑不會(huì)以分隔符結(jié)尾,除非它是根目錄。

func EvalSymlinks

func EvalSymlinks(path string) (string, error)

EvalSymlinks 在評(píng)估任何符號(hào)鏈接后返回路徑名稱。如果路徑是相對(duì)的,則結(jié)果將與當(dāng)前目錄相關(guān),除非其中一個(gè)組件是絕對(duì)符號(hào)鏈接。EvalSymlinks 在結(jié)果上調(diào)用 Clean 。

func Ext

func Ext(path string) string

Ext 返回 path 使用的文件擴(kuò)展名。擴(kuò)展名是從路徑最后一個(gè)元素的最后一個(gè)點(diǎn)開始的后綴; 如果沒有點(diǎn),它是空的。

func FromSlash

func FromSlash(path string) string

FromSlash 返回用分隔符替換路徑中每個(gè)斜杠('/')字符的結(jié)果。多個(gè)斜杠被多個(gè)分隔符替代。

func Glob

func Glob(pattern string) (matches []string, err error)

如果沒有匹配的文件,Glob 返回匹配模式的所有文件的名稱或nil。模式的語法與 Match 中的相同。該模式可以描述分層名稱,例如 / usr / * / bin / ed(假設(shè)分隔符是'/')。

Glob 忽略文件系統(tǒng)錯(cuò)誤,例如讀取目錄的 I/O 錯(cuò)誤。當(dāng)模式格式錯(cuò)誤時(shí),唯一可能返回的錯(cuò)誤是 ErrBadPattern 。

func HasPrefix

func HasPrefix(p, prefix string) bool

HasPrefix 存在歷史兼容性,不應(yīng)使用。

棄用:HasPrefix 不遵守路徑邊界,并且在需要時(shí)不會(huì)忽略大小寫。

func IsAbs

func IsAbs(path string) bool

IsAbs 報(bào)告路徑是否絕對(duì)。

func Join

func Join(elem ...string) string

Join 將任意數(shù)量的路徑元素連接到單個(gè)路徑中,如有必要添加分隔符。加入調(diào)用清理結(jié)果; 特別是,所有空串都被忽略。在 Windows 上,當(dāng)且僅當(dāng)?shù)谝粋€(gè)路徑元素是 UNC 路徑時(shí),結(jié)果為 UNC 路徑。

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

func Match

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

匹配報(bào)告名稱是否與 shell 文件名稱模式相匹配。模式語法是:

pattern:{ term }term:'*'         matches any sequence of non-Separator characters'?'         matches any single non-Separator 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

匹配需要匹配所有名稱的模式,而不僅僅是一個(gè)子字符串。當(dāng)模式格式錯(cuò)誤時(shí),唯一可能返回的錯(cuò)誤是 ErrBadPattern 。

在 Windows 上,轉(zhuǎn)義被禁用。相反,'\'被視為路徑分隔符。

func Rel

func Rel(basepath, targpath string) (string, error)

當(dāng)通過介入分隔符連接到 basepath 時(shí),Rel 返回一個(gè)與 targpath 詞法相同的相對(duì)路徑。也就是說,Join(basepath,Rel(basepath,targpath))等同于 targpath 本身。成功時(shí),即使 basepath 和 targpath 不共享任何元素,返回的路徑也總是相對(duì)于 basepath 。如果無法相對(duì)于基本路徑創(chuàng)建 targpath,或者如果知道當(dāng)前工作目錄來計(jì)算它,則會(huì)返回錯(cuò)誤。Rel 調(diào)用清理結(jié)果。

package mainimport ("fmt""path/filepath")func main() {
	paths := []string{"/a/b/c","/b/c","./b/c",}
	base := "/a"

	fmt.Println("On Unix:")for _, p := range paths {
		rel, err := filepath.Rel(base, p)
		fmt.Printf("%q: %q %v\n", p, rel, err)}}

func Split

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

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

package mainimport ("fmt""path/filepath")func main() {
	paths := []string{"/home/arnie/amelia.jpg","/mnt/photos/","rabbit.jpg","/usr/local//go",}
	fmt.Println("On Unix:")for _, p := range paths {
		dir, file := filepath.Split(p)
		fmt.Printf("input: %q\n\tdir: %q\n\tfile: %q\n", p, dir, file)}}

func SplitList

func SplitList(path string) []string

SplitList 拆分由特定于操作系統(tǒng)的 ListSeparator 連接的路徑列表,通常在 PATH 或 GOPATH 環(huán)境變量中找到。與 strings.Split 不同,SplitList 在傳遞空字符串時(shí)返回空片段。

package mainimport ("fmt""path/filepath")func main() {
	fmt.Println("On Unix:", filepath.SplitList("/a/b/c:/usr/bin"))}

func ToSlash

func ToSlash(path string) string

ToSlash 返回用斜線('/')字符替換路徑中每個(gè)分隔符的結(jié)果。多個(gè)分隔符被多個(gè)斜線替代。

func VolumeName

func VolumeName(path string) string

VolumeName 返回領(lǐng)先的卷名稱。給定“C:\ foo \ bar”,它會(huì)在 Windows 上返回“C:”。鑒于“\host\share\foo”它返回“\host\share”。在其他平臺(tái)上,它返回“”。

func Walk

func Walk(root string, walkFn WalkFunc) error

Walk 遍歷以根為根的文件樹,為樹中的每個(gè)文件或目錄(包括根)調(diào)用 walkFn 。所有訪問文件和目錄的錯(cuò)誤都由 walkFn 過濾。這些文件按照詞匯順序走,這使得輸出具有確定性,但意味著對(duì)于非常大的目錄,Walk 可能效率低下。走并不遵循符號(hào)鏈接。

type WalkFunc

WalkFunc 是 Walk 所訪問的每個(gè)文件或目錄所調(diào)用的函數(shù)的類型。path 參數(shù)包含 Walk 作為前綴的參數(shù); 也就是說,如果使用包含文件“a”的目錄“dir”調(diào)用 Walk,則會(huì)使用參數(shù)“dir / a”調(diào)用 walk 功能。info 參數(shù)是指定路徑的 os.FileInfo 。

如果出現(xiàn)問題時(shí)走到由路徑命名的文件或目錄,傳入的錯(cuò)誤將描述問題,并且函數(shù)可以決定如何處理該錯(cuò)誤(并且 Walk 不會(huì)進(jìn)入該目錄)。如果返回錯(cuò)誤,則處理停止。唯一的例外是函數(shù)返回特殊值 SkipDir 。如果函數(shù)在目錄上調(diào)用時(shí)返回 SkipDir,則 Walk 完全跳過目錄的內(nèi)容。如果函數(shù)在非目錄文件上調(diào)用時(shí)返回 SkipDir,則 Walk 會(huì)跳過包含目錄中的其余文件。

type WalkFunc func(path string, info os.FileInfo, err error) error
Previous article: Next article: