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: encoder.go
    path of file: ./repos/sliver/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/query
    
    the code of the file until where you have to start completion: package query

import (
	"io"
	"net/url"
	"sort"
)

// Encoder is a Query encoder that supports construction of Query body
// values using methods.
type Encoder struct {
	// The query values that will be built up to manage encoding.
	values url.Values
	// The writer that the encoded body will be written to.
	writer io.Writer
	Value
}

// NewEncoder returns a new Query body encoder
func 
    
func (e Encoder) Encode() error {
	ws, ok := e.writer.(interface{ WriteString(string) (int, error) })
	if !ok {
		// Fall back to less optimal byte slice casting if WriteString isn't available.
		ws = &wrapWriteString{writer: e.writer}
	}

	// Get the keys and sort them to have a stable output
	keys := make([]string, 0, len(e.values))
	for k := range e.values {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	isFirstEntry := true
	for _, key := range keys {
		queryValues := e.values[key]
		escapedKey := url.QueryEscape(key)
		for _, value := range queryValues {
			if !isFirstEntry {
				if _, err := ws.WriteString(`&`); err != nil {
					return err
				}
			} else {
				isFirstEntry = false
			}
			if _, err := ws.WriteString(escapedKey); err != nil {
				return err
			}
			if _, err := ws.WriteString(`=`); err != nil {
				return err
			}
			if _, err := ws.WriteString(url.QueryEscape(value)); err != nil {
				return err
			}
		}
	}
	return nil
}