You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: get_environment_metrics_urlbuilder.go
    path of file: ./repos/zrok/rest_server_zrok/operations/metrics
    
    the code of the file until where you have to start completion: // Code generated by go-swagger; DO NOT EDIT.

package metrics

// This file was gene
    
func (o *GetEnvironmentMetricsURL) Build() (*url.URL, error) {
	var _result url.URL

	var _path = "/metrics/environment/{envId}"

	envID := o.EnvID
	if envID != "" {
		_path = strings.Replace(_path, "{envId}", envID, -1)
	} else {
		return nil, errors.New("envId is required on GetEnvironmentMetricsURL")
	}

	_basePath := o._basePath
	if _basePath == "" {
		_basePath = "/api/v1"
	}
	_result.Path = golangswaggerpaths.Join(_basePath, _path)

	qs := make(url.Values)

	var durationQ string
	if o.Duration != nil {
		durationQ = swag.FormatFloat64(*o.Duration)
	}
	if durationQ != "" {
		qs.Set("duration", durationQ)
	}

	_result.RawQuery = qs.Encode()

	return &_result, nil
}