I need to extract the name first of the first directory in a relative path.
I know I can go about:
relPath := "a/b/c/file.so"
splitPath := strings.Split(relPath, string(os.PathSeparator))
rootDirName := splitPath[0]
Is there a better way?
I need to extract the name first of the first directory in a relative path.
I know I can go about:
relPath := "a/b/c/file.so"
splitPath := strings.Split(relPath, string(os.PathSeparator))
rootDirName := splitPath[0]
Is there a better way?
我需要在相对路径中提取第一个目录的名称。 p>
我知道我可以解决: p>
relPath:=“ a / b / c / file.so”
splitPath:= strings.Split(relPath,string( os.PathSeparator))
rootDirName:= splitPath [0]
code> pre>
有没有更好的方法? p>
div>