// Copyright 2015 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.
// Package tag contains functionality handling tags and related data.
package tag // import "golang.org/x/text/internal/tag"import// An Index converts tags to a compact numeric value.//// All elements are of size 4. Tags may be up to 4 bytes long. Excess bytes can// be used to store additional information about the tag.typeIndexstring// Elem returns the element data at the given index.func ( Index) ( int) string {returnstring([*4 : *4+4])}// Index reports the index of the given key or -1 if it could not be found.// Only the first len(key) bytes from the start of the 4-byte entries will be// considered for the search and the first match in Index will be returned.func ( Index) ( []byte) int { := len()// search the index of the first entry with an equal or higher value than // key in s. := sort.Search(len()/4, func( int) bool {returncmp([*4:*4+], ) != -1 }) := * 4ifcmp([:+len()], ) != 0 {return -1 }return}// Next finds the next occurrence of key after index x, which must have been// obtained from a call to Index using the same key. It returns x+1 or -1.func ( Index) ( []byte, int) int {if ++; *4 < len() && cmp([*4:*4+len()], ) == 0 {return }return -1}// cmp returns an integer comparing a and b lexicographically.func cmp( Index, []byte) int { := len()iflen() < { = len() }for , := range [:] {switch {case [] > :return1case [] < :return -1 } }switch {caselen() < len():return -1caselen() > len():return1 }return0}// Compare returns an integer comparing a and b lexicographically.func ( string, []byte) int {returncmp(Index(), )}// FixCase reformats b to the same pattern of cases as form.// If returns false if string b is malformed.func ( string, []byte) bool {iflen() != len() {returnfalse }for , := range {if [] <= 'Z' {if >= 'a' { -= 'z' - 'Z' }if < 'A' || 'Z' < {returnfalse } } else {if <= 'Z' { += 'z' - 'Z' }if < 'a' || 'z' < {returnfalse } } [] = }returntrue}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.