type ValueError … // Parse parses the given BCP 47 string and returns a valid Tag. If parsing // failed it returns an error and any part of the tag that could be parsed. // If parsing succeeded but an unknown value was found, it returns // ValueError. The Tag returned in this case is just stripped of the unknown // value. All other values are preserved. It accepts tags in the BCP 47 format // and extensions to this standard defined in // https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers. // The resulting tag is canonicalized using the default canonicalization type. func Parse(s string) (t Tag, err error) { … } // Parse parses the given BCP 47 string and returns a valid Tag. If parsing // failed it returns an error and any part of the tag that could be parsed. // If parsing succeeded but an unknown value was found, it returns // ValueError. The Tag returned in this case is just stripped of the unknown // value. All other values are preserved. It accepts tags in the BCP 47 format // and extensions to this standard defined in // https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers. // The resulting tag is canonicalized using the canonicalization type c. func (c CanonType) Parse(s string) (t Tag, err error) { … } // Compose creates a Tag from individual parts, which may be of type Tag, Base, // Script, Region, Variant, []Variant, Extension, []Extension or error. If a // Base, Script or Region or slice of type Variant or Extension is passed more // than once, the latter will overwrite the former. Variants and Extensions are // accumulated, but if two extensions of the same type are passed, the latter // will replace the former. For -u extensions, though, the key-type pairs are // added, where later values overwrite older ones. A Tag overwrites all former // values and typically only makes sense as the first argument. The resulting // tag is returned after canonicalizing using the Default CanonType. If one or // more errors are encountered, one of the errors is returned. func Compose(part ...interface{ … } // Compose creates a Tag from individual parts, which may be of type Tag, Base, // Script, Region, Variant, []Variant, Extension, []Extension or error. If a // Base, Script or Region or slice of type Variant or Extension is passed more // than once, the latter will overwrite the former. Variants and Extensions are // accumulated, but if two extensions of the same type are passed, the latter // will replace the former. For -u extensions, though, the key-type pairs are // added, where later values overwrite older ones. A Tag overwrites all former // values and typically only makes sense as the first argument. The resulting // tag is returned after canonicalizing using CanonType c. If one or more errors // are encountered, one of the errors is returned. func (c CanonType) Compose(part ...interface{ … } var errInvalidArgument … func update(b *language.Builder, part ...interface{ … } var errInvalidWeight … var errTagListTooLarge … // ParseAcceptLanguage parses the contents of an Accept-Language header as // defined in http://www.ietf.org/rfc/rfc2616.txt and returns a list of Tags and // a list of corresponding quality weights. It is more permissive than RFC 2616 // and may return non-nil slices even if the input is not valid. // The Tags will be sorted by highest weight first and then by first occurrence. // Tags with a weight of zero will be dropped. An error will be returned if the // input could not be parsed. func ParseAcceptLanguage(s string) (tag []Tag, q []float32, err error) { … } // consume removes a leading token c from s and returns the result or the empty // string if there is no such token. func consume(s string, c byte) string { … } func split(s string, c byte) (head, tail string) { … } var acceptFallback … type tagSort … func (s *tagSort) Len() int { … } func (s *tagSort) Less(i, j int) bool { … } func (s *tagSort) Swap(i, j int) { … }