// GenSpanner generates a spanner DSN from the passed URL.
GenSpanner generates a spanner DSN from the passed URL.
// GenSpanner generates a spanner DSN from the passed URL .
func GenSpanner(u *URL) (string, error) {
	project, instance, dbname := u.Hostname(), "", strings.TrimPrefix(u.Path, "/")
	if project == "" {
		return "", ErrMissingHost
	}
	i := strings.Index(dbname, "/")
	if i == -1 {
		return "", ErrMissingPath
	}
	instance, dbname = dbname[:i], dbname[i+1:]
	if instance == "" || dbname == "" {
		return "", ErrMissingPath
	}
	return fmt.Sprintf(`project/%s/instances/%s/databases/%s`, project, instance, dbname), nil
}
func GenSpanner ( u * URL ) ( string , error ) { project , instance , dbname := u . Hostname ( ) , " " , strings . TrimPrefix ( u . Path , " " ) if project == " " { return " " , ErrMissingHost } i := strings . Index ( dbname , " " ) if i == - 1 { return " " , ErrMissingPath } instance , dbname = dbname [ : i ] , dbname [ i + 1 : ] if instance == " " || dbname == " " { return " " , ErrMissingPath } return fmt . Sprintf ( `project/%s/instances/%s/databases/%s` , project , instance , dbname ) , nil }
GenSpanner generates a spanner DSN from the passed URL.
GenSpanner generates a spanner DSN from the passed URL .