code: func GenFromURL(urlstr string) func(*URL) (string, error) {
  	z, err := url.Parse(urlstr)
  	if err != nil {
  		panic(err)
  	}
  
  	return func(u *URL) (string, error) {
  		opaque := z.Opaque
  		if u.Opaque != "" {
  			opaque = u.Opaque
  		}
  
  		user := z.User
  		if u.User != nil {
  			user = u.User
  		}
  
  		host, port := hostname(z.Host), hostport(z.Host)
  		if h := hostname(u.Host); h != "" {
  			host = h
  		}
  		if p := hostport(u.Host); p != "" {
  			port = p
  		}
  		if port != "" {
  			host += ":" + port
  		}
  
  		path := z.Path
  		if u.Path != "" {
  			path = u.Path
  		}
  
  		rawPath := z.RawPath
  		if u.RawPath != "" {
  			rawPath = u.RawPath
  		}
  
  		q := z.Query()
  		for k, v := range u.Query() {
  			q.Set(k, strings.Join(v, " "))
  		}
  
  		fragment := z.Fragment
  		if u.Fragment != "" {
  			fragment = u.Fragment
  		}
  
  		y := &url.URL{
  			Scheme:   z.Scheme,
  			Opaque:   opaque,
  			User:     user,
  			Host:     host,
  			Path:     path,
  			RawPath:  rawPath,
  			RawQuery: q.Encode(),
  			Fragment: fragment,
  		}
  
  		return y.String(), nil
  	}
  }
docs: // GenFromURL returns a func that generates a DSN using urlstr as the default
  // URL parameters, overriding the values only if when in the passed URL.