github.com/vmware/govmomi@v0.51.0/list/path.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package list 6 7 import ( 8 "path" 9 "strings" 10 ) 11 12 func ToParts(p string) []string { 13 p = path.Clean(p) 14 if p == "/" { 15 return []string{} 16 } 17 18 if len(p) > 0 { 19 // Prefix ./ if relative 20 if p[0] != '/' && p[0] != '.' { 21 p = "./" + p 22 } 23 } 24 25 ps := strings.Split(p, "/") 26 if ps[0] == "" { 27 // Start at root 28 ps = ps[1:] 29 } 30 31 return ps 32 }