MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / NewAttributes

Function NewAttributes

xmlparser/attributes.go:21–37  ·  view source on GitHub ↗

NewAttributes creates a new [Attributes] instance from the given attributes.

(attrs ...*Attribute)

Source from the content-addressed store, hash-verified

19
20// NewAttributes creates a new [Attributes] instance from the given attributes.
21func NewAttributes(attrs ...*Attribute) *Attributes {
22 // If no attributes are provided, return an empty Attributes instance
23 if len(attrs) == 0 {
24 return &Attributes{}
25 }
26
27 // Create a map for quick lookup
28 m := make(map[Name]*Attribute, len(attrs))
29 for _, attr := range attrs {
30 m[attr.Name] = attr
31 }
32
33 return &Attributes{
34 s: attrs,
35 m: m,
36 }
37}
38
39// Get retrieves the value of the attribute with the given name.
40// It returns the value and true if the attribute exists, or an empty string and false otherwise.

Callers 2

readStartTagMethod · 0.85
NewDocumentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected