const maxMembers … const maxBytesPerMembers … const maxBytesPerBaggageString … const listDelimiter … const keyValueDelimiter … const propertyDelimiter … var errInvalidKey … var errInvalidValue … var errInvalidProperty … var errInvalidMember … var errMemberNumber … var errMemberBytes … var errBaggageBytes … type Property … // NewKeyProperty returns a new Property for key. // // If key is invalid, an error will be returned. func NewKeyProperty(key string) (Property, error) { … } // NewKeyValueProperty returns a new Property for key with value. // // The passed key must be compliant with W3C Baggage specification. // The passed value must be percent-encoded as defined in W3C Baggage specification. // // Notice: Consider using [NewKeyValuePropertyRaw] instead // that does not require percent-encoding of the value. func NewKeyValueProperty(key, value string) (Property, error) { … } // NewKeyValuePropertyRaw returns a new Property for key with value. // // The passed key must be compliant with W3C Baggage specification. func NewKeyValuePropertyRaw(key, value string) (Property, error) { … } func newInvalidProperty() Property { … } // parseProperty attempts to decode a Property from the passed string. It // returns an error if the input is invalid according to the W3C Baggage // specification. func parseProperty(property string) (Property, error) { … } // validate ensures p conforms to the W3C Baggage specification, returning an // error otherwise. func (p Property) validate() error { … } // Key returns the Property key. func (p Property) Key() string { … } // Value returns the Property value. Additionally, a boolean value is returned // indicating if the returned value is the empty if the Property has a value // that is empty or if the value is not set. func (p Property) Value() (string, bool) { … } // String encodes Property into a header string compliant with the W3C Baggage // specification. func (p Property) String() string { … } type properties … func fromInternalProperties(iProps []baggage.Property) properties { … } func (p properties) asInternal() []baggage.Property { … } func (p properties) Copy() properties { … } // validate ensures each Property in p conforms to the W3C Baggage // specification, returning an error otherwise. func (p properties) validate() error { … } // String encodes properties into a header string compliant with the W3C Baggage // specification. func (p properties) String() string { … } type Member … // NewMember returns a new Member from the passed arguments. // // The passed key must be compliant with W3C Baggage specification. // The passed value must be percent-encoded as defined in W3C Baggage specification. // // Notice: Consider using [NewMemberRaw] instead // that does not require percent-encoding of the value. func NewMember(key, value string, props ...Property) (Member, error) { … } // NewMemberRaw returns a new Member from the passed arguments. // // The passed key must be compliant with W3C Baggage specification. func NewMemberRaw(key, value string, props ...Property) (Member, error) { … } func newInvalidMember() Member { … } // parseMember attempts to decode a Member from the passed string. It returns // an error if the input is invalid according to the W3C Baggage // specification. func parseMember(member string) (Member, error) { … } // validate ensures m conforms to the W3C Baggage specification. // A key must be an ASCII string, returning an error otherwise. func (m Member) validate() error { … } // Key returns the Member key. func (m Member) Key() string { … } // Value returns the Member value. func (m Member) Value() string { … } // Properties returns a copy of the Member properties. func (m Member) Properties() []Property { … } // String encodes Member into a header string compliant with the W3C Baggage // specification. func (m Member) String() string { … } type Baggage … // New returns a new valid Baggage. It returns an error if it results in a // Baggage exceeding limits set in that specification. // // It expects all the provided members to have already been validated. func New(members ...Member) (Baggage, error) { … } // Parse attempts to decode a baggage-string from the passed string. It // returns an error if the input is invalid according to the W3C Baggage // specification. // // If there are duplicate list-members contained in baggage, the last one // defined (reading left-to-right) will be the only one kept. This diverges // from the W3C Baggage specification which allows duplicate list-members, but // conforms to the OpenTelemetry Baggage specification. func Parse(bStr string) (Baggage, error) { … } // Member returns the baggage list-member identified by key. // // If there is no list-member matching the passed key the returned Member will // be a zero-value Member. // The returned member is not validated, as we assume the validation happened // when it was added to the Baggage. func (b Baggage) Member(key string) Member { … } // Members returns all the baggage list-members. // The order of the returned list-members does not have significance. // // The returned members are not validated, as we assume the validation happened // when they were added to the Baggage. func (b Baggage) Members() []Member { … } // SetMember returns a copy the Baggage with the member included. If the // baggage contains a Member with the same key the existing Member is // replaced. // // If member is invalid according to the W3C Baggage specification, an error // is returned with the original Baggage. func (b Baggage) SetMember(member Member) (Baggage, error) { … } // DeleteMember returns a copy of the Baggage with the list-member identified // by key removed. func (b Baggage) DeleteMember(key string) Baggage { … } // Len returns the number of list-members in the Baggage. func (b Baggage) Len() int { … } // String encodes Baggage into a header string compliant with the W3C Baggage // specification. func (b Baggage) String() string { … } // parsePropertyInternal attempts to decode a Property from the passed string. // It follows the spec at https://www.w3.org/TR/baggage/#definition. func parsePropertyInternal(s string) (p Property, ok bool) { … } func skipSpace(s string, offset int) int { … } var safeKeyCharset … func validateKey(s string) bool { … } func validateKeyChar(c int32) bool { … } func validateValue(s string) bool { … } var safeValueCharset … func validateValueChar(c int32) bool { … } // valueEscape escapes the string so it can be safely placed inside a baggage value, // replacing special characters with %XX sequences as needed. // // The implementation is based on: // https://github.com/golang/go/blob/f6509cf5cdbb5787061b784973782933c47f1782/src/net/url/url.go#L285. func valueEscape(s string) string { … } // shouldEscape returns true if the specified byte should be escaped when // appearing in a baggage value string. func shouldEscape(c byte) bool { … }