github.com/0chain/gosdk@v1.17.11/core/common/utils.go (about) 1 // Provides the data structures and methods to work with the common data structures. 2 package common 3 4 import ( 5 "fmt" 6 "path" 7 "strings" 8 9 "github.com/valyala/bytebufferpool" 10 ) 11 12 var MemPool bytebufferpool.Pool 13 14 func GetPathFields(p string) ([]string, error) { 15 if p == "" || p == "/" { 16 return nil, nil 17 } 18 19 if !path.IsAbs(p) { 20 return nil, fmt.Errorf("path %s is not absolute", p) 21 } 22 23 p = path.Clean(p) 24 fields := strings.Split(p, "/") 25 return fields[1:], nil 26 }