diff --git a/document/cbor/decode.go b/document/cbor/decode.go index c998989a7..275482b09 100644 --- a/document/cbor/decode.go +++ b/document/cbor/decode.go @@ -48,7 +48,7 @@ func (d *decoder) Decode(v cbor.Value, to interface{}) error { rv := reflect.ValueOf(to) if rv.Kind() != reflect.Ptr || rv.IsNil() || !rv.IsValid() { - return &document.InvalidUnmarshalError{reflect.TypeOf(to)} + return &document.InvalidUnmarshalError{Type: reflect.TypeOf(to)} } return d.decode(v, rv, serde.Tag{}) diff --git a/document/cbor/encode.go b/document/cbor/encode.go index 7ad7f43ff..3b0fd98b7 100644 --- a/document/cbor/encode.go +++ b/document/cbor/encode.go @@ -145,7 +145,7 @@ func (e *encoder) encodeMap(rv reflect.Value) (cbor.Map, error) { for _, key := range rv.MapKeys() { keyName := fmt.Sprint(key.Interface()) if keyName == "" { - return nil, &document.InvalidMarshalError{"map key cannot be empty"} + return nil, &document.InvalidMarshalError{Message: "map key cannot be empty"} } cv, err := e.encode(rv.MapIndex(key), serde.Tag{}) diff --git a/encoding/cbor/encode.go b/encoding/cbor/encode.go index 646f5b68c..8c88cb015 100644 --- a/encoding/cbor/encode.go +++ b/encoding/cbor/encode.go @@ -189,7 +189,7 @@ func (v EncodeRaw) encode(p []byte) int { return len(v) } -// FixedUint encodes fixed-width Uint values. +// EncodeFixedUint encodes fixed-width Uint values. // // This is used by the encoder for the purpose of embedding integrals in // document shapes. Decode will never return values of this type. @@ -203,7 +203,7 @@ func (v EncodeFixedUint) encode(p []byte) int { return 9 } -// FixedUint encodes fixed-width NegInt values. +// EncodeFixedNegInt encodes fixed-width NegInt values. // // This is used by the encoder for the purpose of embedding integrals in // document shapes. Decode will never return values of this type. diff --git a/encoding/doc.go b/encoding/doc.go index 792fdfa08..f3c93df49 100644 --- a/encoding/doc.go +++ b/encoding/doc.go @@ -1,4 +1,3 @@ // Package encoding provides utilities for encoding values for specific // document encodings. - package encoding diff --git a/encoding/httpbinding/encode.go b/encoding/httpbinding/encode.go index 543e7cf03..bde78aca2 100644 --- a/encoding/httpbinding/encode.go +++ b/encoding/httpbinding/encode.go @@ -33,7 +33,7 @@ func NewEncoder(path, query string, headers http.Header) (*Encoder, error) { return NewEncoderWithRawPath(path, path, query, headers) } -// NewHTTPBindingEncoder creates a new encoder from the passed in request. All query and +// NewEncoderWithRawPath creates a new encoder from the passed in request. All query and // header values will be added on top of the request's existing values. Overwriting // duplicate values. func NewEncoderWithRawPath(path, rawPath, query string, headers http.Header) (*Encoder, error) { diff --git a/endpoints/private/rulesfn/doc.go b/endpoints/private/rulesfn/doc.go index e24e190dc..53b430e3e 100644 --- a/endpoints/private/rulesfn/doc.go +++ b/endpoints/private/rulesfn/doc.go @@ -1,4 +1,3 @@ // Package rulesfn provides endpoint rule functions for evaluating endpoint // resolution rules. - package rulesfn diff --git a/endpoints/private/rulesfn/strings.go b/endpoints/private/rulesfn/strings.go index 5cf4a7b02..088cfb3e8 100644 --- a/endpoints/private/rulesfn/strings.go +++ b/endpoints/private/rulesfn/strings.go @@ -1,6 +1,6 @@ package rulesfn -// Substring returns the substring of the input provided. If the start or stop +// SubString returns the substring of the input provided. If the start or stop // indexes are not valid for the input nil will be returned. If errors occur // they will be added to the provided [ErrorCollector]. func SubString(input string, start, stop int, reverse bool) *string { diff --git a/endpoints/private/rulesfn/uri.go b/endpoints/private/rulesfn/uri.go index 0c1154127..340d4ec34 100644 --- a/endpoints/private/rulesfn/uri.go +++ b/endpoints/private/rulesfn/uri.go @@ -71,7 +71,7 @@ func ParseURL(input string) *URL { Authority: authority, Path: u.Path, NormalizedPath: normalizedPath, - IsIp: net.ParseIP(hostnameWithoutZone(u)) != nil, + IsIP: net.ParseIP(hostnameWithoutZone(u)) != nil, } } @@ -82,7 +82,7 @@ type URL struct { Authority string // https://www.rfc-editor.org/rfc/rfc3986#section-3.2 Path string // https://www.rfc-editor.org/rfc/rfc3986#section-3.3 NormalizedPath string // https://www.rfc-editor.org/rfc/rfc3986#section-6.2.3 - IsIp bool + IsIP bool } // URIEncode returns an percent-encoded [RFC3986 section 2.1] version of the diff --git a/endpoints/private/rulesfn/uri_test.go b/endpoints/private/rulesfn/uri_test.go index 0a001a8fc..49504cde3 100644 --- a/endpoints/private/rulesfn/uri_test.go +++ b/endpoints/private/rulesfn/uri_test.go @@ -76,7 +76,7 @@ func TestParseURL(t *testing.T) { Authority: "127.0.0.1", Path: "", NormalizedPath: "/", - IsIp: true, + IsIP: true, }, }, "ip4 URL with port": { @@ -86,7 +86,7 @@ func TestParseURL(t *testing.T) { Authority: "127.0.0.1:8443", Path: "", NormalizedPath: "/", - IsIp: true, + IsIP: true, }, }, "ip6 short": { @@ -96,7 +96,7 @@ func TestParseURL(t *testing.T) { Authority: "[fe80::1]", Path: "", NormalizedPath: "/", - IsIp: true, + IsIP: true, }, }, "ip6 short with interface": { @@ -106,7 +106,7 @@ func TestParseURL(t *testing.T) { Authority: "[fe80::1%25en0]", Path: "", NormalizedPath: "/", - IsIp: true, + IsIP: true, }, }, "ip6 short with port": { @@ -116,7 +116,7 @@ func TestParseURL(t *testing.T) { Authority: "[fe80::1]:8443", Path: "", NormalizedPath: "/", - IsIp: true, + IsIP: true, }, }, "ip6 short with port with interface": { @@ -126,7 +126,7 @@ func TestParseURL(t *testing.T) { Authority: "[fe80::1%25en0]:8443", Path: "", NormalizedPath: "/", - IsIp: true, + IsIP: true, }, }, } diff --git a/internal/sync/singleflight/docs.go b/internal/sync/singleflight/docs.go index 9c9d02b94..cb70616e8 100644 --- a/internal/sync/singleflight/docs.go +++ b/internal/sync/singleflight/docs.go @@ -4,5 +4,4 @@ // and unversioned golang.org/x/sync module. // // https://github.com/golang/sync/tree/67f06af15bc961c363a7260195bcd53487529a21/singleflight - package singleflight diff --git a/middleware/stack_values.go b/middleware/stack_values.go index ef96009ba..97e818ca0 100644 --- a/middleware/stack_values.go +++ b/middleware/stack_values.go @@ -21,7 +21,7 @@ func ClearStackValues(ctx context.Context) context.Context { return context.WithValue(ctx, stackValuesKey{}, nil) } -// GetStackValues returns the value pointed to by the key within the stack +// GetStackValue returns the value pointed to by the key within the stack // values, if it is present. func GetStackValue(ctx context.Context, key interface{}) interface{} { md, _ := ctx.Value(stackValuesKey{}).(*stackValues) @@ -62,13 +62,13 @@ func (m *stackValues) Value(key interface{}) interface{} { return m.parent.Value(key) } -func (c *stackValues) String() string { +func (m *stackValues) String() string { var str strings.Builder - cc := c + cc := m for cc == nil { str.WriteString("(" + - reflect.TypeOf(c.key).String() + + reflect.TypeOf(m.key).String() + ": " + stringify(cc.value) + ")") diff --git a/private/requestcompression/request_compression.go b/private/requestcompression/request_compression.go index 7c4147603..caabc4c8b 100644 --- a/private/requestcompression/request_compression.go +++ b/private/requestcompression/request_compression.go @@ -10,12 +10,14 @@ import ( "bytes" "context" "fmt" + "io" + "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/transport/http" - "io" ) -const MaxRequestMinCompressSizeBytes = 10485760 +// MaxRequestMinCompressSizeBytes is the maximum value allowed for the member MinCompressSizeBytes +const MaxRequestMinCompressSizeBytes = 10485760 // 10 MB // Enumeration values for supported compress Algorithms. const ( diff --git a/testing/bytes.go b/testing/bytes.go index 955612552..c223f6e2b 100644 --- a/testing/bytes.go +++ b/testing/bytes.go @@ -16,7 +16,7 @@ const ( type compareCompressFunc func([]byte, io.Reader) error var allowedAlgorithms = map[string]compareCompressFunc{ - GZIP: GzipCompareCompressBytes, + GZIP: gzipCompareCompressBytes, } // CompareReaderEmpty checks if the reader is nil, or contains no bytes. diff --git a/testing/gzip.go b/testing/gzip.go index e6f4d6524..1f5acd13f 100644 --- a/testing/gzip.go +++ b/testing/gzip.go @@ -7,7 +7,7 @@ import ( "io" ) -func GzipCompareCompressBytes(expect []byte, actual io.Reader) error { +func gzipCompareCompressBytes(expect []byte, actual io.Reader) error { content, err := gzip.NewReader(actual) if err != nil { return fmt.Errorf("error while reading request") diff --git a/testing/xml/doc.go b/testing/xml/doc.go index 7282681cf..eff6fb122 100644 --- a/testing/xml/doc.go +++ b/testing/xml/doc.go @@ -1,6 +1,6 @@ -// package xml is xml testing package that supports xml comparison utility. -// The package consists of XMLToStruct and StructToXML utils that help sort xml elements -// as per their nesting level. XMLToStruct function converts an xml document into a sorted +// Package xml is xml testing package that supports xml comparison utility. +// The package consists of ToStruct and StructToXML utils that help sort xml elements +// as per their nesting level. ToStruct function converts a xml document into a sorted // tree node structure, while StructToXML converts the sorted xml nodes into a sorted xml document. -// SortXML function should be used to sort an xml document. It can be configured to ignore indentation +// SortXML function should be used to sort a xml document. It can be configured to ignore indentation package xml diff --git a/testing/xml/sort.go b/testing/xml/sort.go index 19a06b580..e4fcd328b 100644 --- a/testing/xml/sort.go +++ b/testing/xml/sort.go @@ -37,7 +37,7 @@ func (x xmlAttrSlice) Swap(i, j int) { func SortXML(r io.Reader, ignoreIndentation bool) (string, error) { var buf bytes.Buffer d := xml.NewDecoder(r) - root, err := XMLToStruct(d, nil, ignoreIndentation) + root, err := ToStruct(d, nil, ignoreIndentation) if err != nil { return buf.String(), err } diff --git a/testing/xml/xmlToStruct.go b/testing/xml/xmlToStruct.go index 1bfc7ba98..d56f5fd91 100644 --- a/testing/xml/xmlToStruct.go +++ b/testing/xml/xmlToStruct.go @@ -8,39 +8,39 @@ import ( "strings" ) -// A XMLNode contains the values to be encoded or decoded. -type XMLNode struct { - Name xml.Name `json:",omitempty"` - Children map[string][]*XMLNode `json:",omitempty"` - Text string `json:",omitempty"` - Attr []xml.Attr `json:",omitempty"` +// Node contains the values to be encoded or decoded. +type Node struct { + Name xml.Name `json:",omitempty"` + Children map[string][]*Node `json:",omitempty"` + Text string `json:",omitempty"` + Attr []xml.Attr `json:",omitempty"` namespaces map[string]string - parent *XMLNode + parent *Node } // NewXMLElement returns a pointer to a new XMLNode initialized to default values. -func NewXMLElement(name xml.Name) *XMLNode { - return &XMLNode{ +func NewXMLElement(name xml.Name) *Node { + return &Node{ Name: name, - Children: map[string][]*XMLNode{}, + Children: map[string][]*Node{}, Attr: []xml.Attr{}, } } // AddChild adds child to the XMLNode. -func (n *XMLNode) AddChild(child *XMLNode) { +func (n *Node) AddChild(child *Node) { child.parent = n if _, ok := n.Children[child.Name.Local]; !ok { // flattened will have multiple children with same tag name - n.Children[child.Name.Local] = []*XMLNode{} + n.Children[child.Name.Local] = []*Node{} } n.Children[child.Name.Local] = append(n.Children[child.Name.Local], child) } -// XMLToStruct converts a xml.Decoder stream to XMLNode with nested values. -func XMLToStruct(d *xml.Decoder, s *xml.StartElement, ignoreIndentation bool) (*XMLNode, error) { - out := &XMLNode{} +// ToStruct converts a xml.Decoder stream to XMLNode with nested values. +func ToStruct(d *xml.Decoder, s *xml.StartElement, ignoreIndentation bool) (*Node, error) { + out := &Node{} for { tok, err := d.Token() @@ -69,15 +69,15 @@ func XMLToStruct(d *xml.Decoder, s *xml.StartElement, ignoreIndentation bool) (* el := typed.Copy() out.Attr = el.Attr if out.Children == nil { - out.Children = map[string][]*XMLNode{} + out.Children = map[string][]*Node{} } name := typed.Name.Local slice := out.Children[name] if slice == nil { - slice = []*XMLNode{} + slice = []*Node{} } - node, e := XMLToStruct(d, &el, ignoreIndentation) + node, e := ToStruct(d, &el, ignoreIndentation) out.findNamespaces() if e != nil { return out, e @@ -99,13 +99,13 @@ func XMLToStruct(d *xml.Decoder, s *xml.StartElement, ignoreIndentation bool) (* if s != nil && s.Name.Local == typed.Name.Local { // matching end token return out, nil } - out = &XMLNode{} + out = &Node{} } } return out, nil } -func (n *XMLNode) findNamespaces() { +func (n *Node) findNamespaces() { ns := map[string]string{} for _, a := range n.Attr { if a.Name.Space == "xmlns" { @@ -116,7 +116,7 @@ func (n *XMLNode) findNamespaces() { n.namespaces = ns } -func (n *XMLNode) findElem(name string) (string, bool) { +func (n *Node) findElem(name string) (string, bool) { for node := n; node != nil; node = node.parent { for _, a := range node.Attr { namespace := a.Name.Space @@ -132,7 +132,7 @@ func (n *XMLNode) findElem(name string) (string, bool) { } // StructToXML writes an XMLNode to a xml.Encoder as tokens. -func StructToXML(e *xml.Encoder, node *XMLNode, sorted bool) error { +func StructToXML(e *xml.Encoder, node *Node, sorted bool) error { var err error // Sort Attributes attrs := node.Attr @@ -206,21 +206,21 @@ func StructToXML(e *xml.Encoder, node *XMLNode, sorted bool) error { // which ever has lower value and then added to the global sorted list. // If value was initially chosen, but has nested nodes; key will be chosen as comparable // as it is unique and will always have concrete data ie. string. -func sortFlattenedNodes(nodes []*XMLNode) ([]*XMLNode, error) { - var sortedNodes []*XMLNode +func sortFlattenedNodes(nodes []*Node) ([]*Node, error) { + var sortedNodes []*Node // concreteNodeMap stores concrete value associated with a list of nodes // This is possible in case multiple members of a flatList has same values. - concreteNodeMap := make(map[string][]*XMLNode, 0) + concreteNodeMap := make(map[string][]*Node, 0) // flatListNodeMap stores flat list or wrapped list members associated with a list of nodes // This will have only flattened list with members that are Nodes and not concrete values. - flatListNodeMap := make(map[string][]*XMLNode, 0) + flatListNodeMap := make(map[string][]*Node, 0) // flatMapNodeMap stores flat map or map entry members associated with a list of nodes // This will have only flattened map concrete value members. It is possible to limit this // to concrete value as map key is expected to be concrete. - flatMapNodeMap := make(map[string][]*XMLNode, 0) + flatMapNodeMap := make(map[string][]*Node, 0) // nodes with concrete value are prioritized and appended based on sorting order sortedNodesWithConcreteValue := []string{} @@ -238,7 +238,7 @@ func sortFlattenedNodes(nodes []*XMLNode) ([]*XMLNode, error) { if v, ok := concreteNodeMap[node.Text]; ok { concreteNodeMap[node.Text] = append(v, node) } else { - concreteNodeMap[node.Text] = []*XMLNode{node} + concreteNodeMap[node.Text] = []*Node{node} } } @@ -253,14 +253,14 @@ func sortFlattenedNodes(nodes []*XMLNode) ([]*XMLNode, error) { if v, ok := flatListNodeMap[nestedNodeName]; ok { flatListNodeMap[nestedNodeName] = append(v, nestedNodes[0]) } else { - flatListNodeMap[nestedNodeName] = []*XMLNode{nestedNodes[0]} + flatListNodeMap[nestedNodeName] = []*Node{nestedNodes[0]} } } } // if node has two children, then it is a flattened map node if len(node.Children) == 2 { - nestedPair := []*XMLNode{} + nestedPair := []*Node{} for _, k := range node.Children { nestedPair = append(nestedPair, k[0]) } @@ -285,7 +285,7 @@ func sortFlattenedNodes(nodes []*XMLNode) ([]*XMLNode, error) { if v, ok := flatMapNodeMap[comparableValue]; ok { flatMapNodeMap[comparableValue] = append(v, node) } else { - flatMapNodeMap[comparableValue] = []*XMLNode{node} + flatMapNodeMap[comparableValue] = []*Node{node} } break } diff --git a/transport/http/headerlist.go b/transport/http/headerlist.go index cbc9deb4d..3c7c1edf6 100644 --- a/transport/http/headerlist.go +++ b/transport/http/headerlist.go @@ -55,7 +55,7 @@ func quotedCommaSplit(v string) (parts []string, err error) { //------------------------------ var j int var skipQuote bool - for j += 1; j < len(remaining); j++ { + for j ++; j < len(remaining); j++ { if remaining[j] == '\\' || (remaining[j] != '\\' && skipQuote) { skipQuote = !skipQuote continue diff --git a/transport/http/properties.go b/transport/http/properties.go index c65aa3932..060858832 100644 --- a/transport/http/properties.go +++ b/transport/http/properties.go @@ -46,7 +46,7 @@ func SetSigV4ASigningName(p *smithy.Properties, name string) { p.Set(sigV4ASigningNameKey{}, name) } -// GetSigV4ASigningRegion gets the v4a signing region set from Properties. +// GetSigV4ASigningRegions gets the v4a signing region set from Properties. func GetSigV4ASigningRegions(p *smithy.Properties) ([]string, bool) { v, ok := p.Get(sigV4ASigningRegionsKey{}).([]string) return v, ok