github.com/vmware/go-vcloud-director/v2@v2.24.0/govcd/vcd_test_help.go (about)

     1  package govcd
     2  
     3  import "strings"
     4  
     5  // Gets the two or three components of a "parent" string, as passed to AddToCleanupList
     6  // If the number of split strings is not 2 or 3 it return 3 empty strings
     7  // Example input parent: my-org|my-vdc|my-edge-gw, separator: |
     8  // Output : first: my-org, second: my-vdc, third: my-edge-gw
     9  func splitParent(parent string, separator string) (first, second, third string) {
    10  	strList := strings.Split(parent, separator)
    11  	if len(strList) < 2 || len(strList) > 3 {
    12  		return "", "", ""
    13  	}
    14  	first = strList[0]
    15  	second = strList[1]
    16  
    17  	if len(strList) == 3 {
    18  		third = strList[2]
    19  	}
    20  
    21  	return
    22  }