// GenOracle generates a Go Driver for Oracle (godror) DSN from the passed URL.
GenOracle generates a Go Driver for Oracle (godror) DSN from the passed URL.
// GenOracle generates a Go Driver for Oracle ( godror ) DSN from the passed URL .
func GenOracle(u *URL) (string, error) {
	host, port, service := u.Hostname(), u.Port(), strings.TrimPrefix(u.Path, "/")
	var instance string
	if i := strings.LastIndex(service, "/"); i != -1 {
		instance, service = service[i+1:], service[:i]
	}
	dsn := host
	if port != "" {
		dsn += ":" + port
	}
	if u.User != nil {
		if n := u.User.Username(); n != "" {
			if p, ok := u.User.Password(); ok {
				n += "/" + p
			}
			dsn = n + "@//" + dsn
		}
	}
	if service != "" {
		dsn += "/" + service
	}
	if instance != "" {
		dsn += "/" + instance
	}
	return dsn, nil
}
func GenOracle ( u * URL ) ( string , error ) { host , port , service := u . Hostname ( ) , u . Port ( ) , strings . TrimPrefix ( u . Path , " " ) var instance string if i := strings . LastIndex ( service , " " ) ; i != - 1 { instance , service = service [ i + 1 : ] , service [ : i ] } dsn := host if port != " " { dsn += " " + port } if u . User != nil { if n := u . User . Username ( ) ; n != " " { if p , ok := u . User . Password ( ) ; ok { n += " " + p } dsn = n + " " + dsn } } if service != " " { dsn += " " + service } if instance != " " { dsn += " " + instance } return dsn , nil }
GenOracle generates a Go Driver for Oracle (godror) DSN from the passed URL.
GenOracle generates a Go Driver for Oracle ( godror ) DSN from the passed URL .
// Easy Connect Naming method enables clients to connect to a database server // without any configuration. Clients use a connect string for a simple TCP/IP // address, which includes a host name and optional port and service name: // CONNECT username[/password]@[//]host[:port][/service_name][:server][/instance_name] // grab instance name from service name // build dsn