...

Text file src/cmd/go/testdata/mod/golang.org_x_text_v0.3.0.txt

Documentation: cmd/go/testdata/mod

     1written by hand - just enough to compile rsc.io/sampler, rsc.io/quote
     2
     3-- .mod --
     4module golang.org/x/text
     5-- .info --
     6{"Version":"v0.3.0","Name":"","Short":"","Time":"2017-09-16T03:28:32Z"}
     7-- go.mod --
     8module golang.org/x/text
     9-- unused/unused.go --
    10package unused
    11-- language/lang.go --
    12// Copyright 2018 The Go Authors. All rights reserved.
    13// Use of this source code is governed by a BSD-style
    14// license that can be found in the LICENSE file.
    15
    16// This is a tiny version of golang.org/x/text.
    17
    18package language
    19
    20import "strings"
    21
    22type Tag string
    23
    24func Make(s string) Tag { return Tag(s) }
    25
    26func (t Tag) String() string { return string(t) }
    27
    28func NewMatcher(tags []Tag) Matcher { return &matcher{tags} }
    29
    30type Matcher interface {
    31	Match(...Tag) (Tag, int, int)
    32}
    33
    34type matcher struct {
    35	tags []Tag
    36}
    37
    38func (m *matcher) Match(prefs ...Tag) (Tag, int, int) {
    39	for _, pref := range prefs {
    40		for _, tag := range m.tags {
    41			if tag == pref || strings.HasPrefix(string(pref), string(tag+"-")) || strings.HasPrefix(string(tag), string(pref+"-")) {
    42				return tag, 0, 0
    43			}
    44		}
    45	}
    46	return m.tags[0], 0, 0
    47}

View as plain text