dsn.go
func GenPresto(u *URL) (string, error) {
	z := &url.URL{
		Scheme:   "http",
		Opaque:   u.Opaque,
		User:     u.User,
		Host:     u.Host,
		RawQuery: u.RawQuery,
		Fragment: u.Fragment,
	}

	// change to https
	if strings.HasSuffix(u.OriginalScheme, "s") {
		z.Scheme = "https"
	}

	// force user
	if z.User == nil {
		z.User = url.User("user")
	}

	// force host
	if z.Host == "" {
		z.Host = "localhost"
	}

	// force port
	if hostport(z.Host) == "" {
		if z.Scheme == "http" {
			z.Host += ":8080"
		} else if z.Scheme == "https" {
			z.Host += ":8443"
		}
	}

	// add parameters
	q := z.Query()
	dbname, schema := strings.TrimPrefix(u.Path, "/"), ""
	if dbname == "" {
		dbname = "default"
	} else if i := strings.Index(dbname, "/"); i != -1 {
		schema, dbname = dbname[i+1:], dbname[:i]
	}
	q.Set("catalog", dbname)
	if schema != "" {
		q.Set("schema", schema)
	}
	z.RawQuery = q.Encode()

	return z.String(), nil
}
func GenPresto(u *URL) (string, error) {
	z := &url.URL{
		Scheme:   "http",
		Opaque:   u.Opaque,
		User:     u.User,
		Host:     u.Host,
		RawQuery: u.RawQuery,
		Fragment: u.Fragment,
	}

	// change to https
	if strings.HasSuffix(u.OriginalScheme, "s") {
		z.Scheme = "https"
	}

	// force user
	if z.User == nil {
		z.User = url.User("user")
	}

	// force host
	if z.Host == "" {
		z.Host = "localhost"
	}

	// force port
	if hostport(z.Host) == "" {
		if z.Scheme == "http" {
			z.Host += ":8080"
		} else if z.Scheme == "https" {
			z.Host += ":8443"
		}
	}

	// add parameters
	q := z.Query()
	dbname, schema := strings.TrimPrefix(u.Path, "/"), ""
	if dbname == "" {
		dbname = "default"
	} else if i := strings.Index(dbname, "/"); i != -1 {
		schema, dbname = dbname[i+1:], dbname[:i]
	}
	q.Set("catalog", dbname)
	if schema != "" {
		q.Set("schema", schema)
	}
	z.RawQuery = q.Encode()

	return z.String(), nil
}
func GenPresto ( u * URL ) ( string , error ) { z := & url . URL { Scheme : " " , Opaque : u . Opaque , User : u . User , Host : u . Host , RawQuery : u . RawQuery , Fragment : u . Fragment , } // change to https if strings . HasSuffix ( u . OriginalScheme , " " ) { z . Scheme = " " } // force user if z . User == nil { z . User = url . User ( " " ) } // force host if z . Host == " " { z . Host = " " } // force port if hostport ( z . Host ) == " " { if z . Scheme == " " { z . Host += " " } else if z . Scheme == " " { z . Host += " " } } // add parameters q := z . Query ( ) dbname , schema := strings . TrimPrefix ( u . Path , " " ) , " " if dbname == " " { dbname = " " } else if i := strings . Index ( dbname , " " ) ; i != - 1 { schema , dbname = dbname [ i + 1 : ] , dbname [ : i ] } q . Set ( " " , dbname ) if schema != " " { q . Set ( " " , schema ) } z . RawQuery = q . Encode ( ) return z . String ( ) , nil }
// GenPresto generates a Presto DSN from the passed URL.
GenPresto generates a Presto DSN from the passed URL .