Source File
path_unix.go
Belonging Package
os
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build unix || (js && wasm) || wasip1
package os
const (
PathSeparator = '/' // OS-specific path separator
PathListSeparator = ':' // OS-specific path list separator
)
// IsPathSeparator reports whether c is a directory separator character.
func ( uint8) bool {
return PathSeparator ==
}
// basename removes trailing slashes and the leading directory name from path name.
func ( string) string {
:= len() - 1
// Remove trailing slashes
for ; > 0 && [] == '/'; -- {
= [:]
}
// Remove leading directory name
for --; >= 0; -- {
if [] == '/' {
= [+1:]
break
}
}
return
}
// splitPath returns the base name and parent directory.
func ( string) (string, string) {
// if no better parent is found, the path is relative from "here"
:= "."
// Remove all but one leading slash.
for len() > 1 && [0] == '/' && [1] == '/' {
= [1:]
}
:= len() - 1
// Remove trailing slashes.
for ; > 0 && [] == '/'; -- {
= [:]
}
// if no slashes in path, base is path
:=
// Remove leading directory path
for --; >= 0; -- {
if [] == '/' {
if == 0 {
= [:1]
} else {
= [:]
}
= [+1:]
break
}
}
return ,
}
func ( string) string {
return
}
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |