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.// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solarispackage osconst (PathSeparator = '/' // OS-specific path separatorPathListSeparator = ':' // 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 slashesfor ; > 0 && [] == '/'; -- {= [:]}// Remove leading directory namefor --; >= 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 pathfor --; >= 0; -- {if [] == '/' {if == 0 {= [:1]} else {= [:]}= [+1:]break}}return ,}func ( string) string {return}