// smartAlias returns a "unique" import alias for a package as slice of path sections.
// Note this is very luno specific.
smartAlias returns a "unique" import alias for a package as slice of path sections.
Note this is very luno specific.
// smartAlias returns a " unique " import alias for a package as slice of path sections . // Note this is very luno specific .
func smartAlias(pkgPath string) []string {
	more := map[string]bool{
		"client":  true,
		"ops":     true,
		"server":  true,
		"db":      true,
		"grpc":    true,
		"logical": true,
		"dev":     true,
		"state":   true,
	}
	pkgParts := strings.Split(pkgPath, "/")
	var res []string
	for i := len(pkgParts) - 1; i >= 0; i-- {
		part := strings.ReplaceAll(pkgParts[i], "-", "")
		if strings.HasPrefix(part, "v") {
			_, err := strconv.Atoi(part[1:])
			if err != nil {
			} else {
				res = append([]string{part}, res...)
				continue
			}
		}
		res = append([]string{part}, res...)
		if part == "bitx" || !more[part] {
			break
		}
	}
	return res
}
func smartAlias ( pkgPath string ) [ ] string { more := map [ string ] bool { " " : true , " " : true , " " : true , " " : true , " " : true , " " : true , " " : true , " " : true , } pkgParts := strings . Split ( pkgPath , " " ) var res [ ] string for i := len ( pkgParts ) - 1 ; i >= 0 ; i -- { part := strings . ReplaceAll ( pkgParts [ i ] , " " , " " ) if strings . HasPrefix ( part , " " ) { _ , err := strconv . Atoi ( part [ 1 : ] ) if err != nil { } else { res = append ( [ ] string { part } , res ... ) continue } } res = append ( [ ] string { part } , res ... ) if part == " " || ! more [ part ] { break } } return res }
smartAlias returns a "unique" import alias for a package as slice of path sections.
smartAlias returns a " unique " import alias for a package as slice of path sections .
// NoReturnErr: We're checking if this is a number. // This is a versioned import. Include the version as well as // the next part.