Debian Codegraph @

internal/language/tags.go

raw
1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package language
6
7 // MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed.
8 // It simplifies safe initialization of Tag values.
9 func MustParse(s string) Tag {
10 t, err := Parse(s)
11 if err != nil {
12 panic(err)
13 }
14 return t
15 }
16
17 // MustParseBase is like ParseBase, but panics if the given base cannot be parsed.
18 // It simplifies safe initialization of Base values.
19 func MustParseBase(s string) Language {
20 b, err := ParseBase(s)
21 if err != nil {
22 panic(err)
23 }
24 return b
25 }
26
27 // MustParseScript is like ParseScript, but panics if the given script cannot be
28 // parsed. It simplifies safe initialization of Script values.
29 func MustParseScript(s string) Script {
30 scr, err := ParseScript(s)
31 if err != nil {
32 panic(err)
33 }
34 return scr
35 }
36
37 // MustParseRegion is like ParseRegion, but panics if the given region cannot be
38 // parsed. It simplifies safe initialization of Region values.
39 func MustParseRegion(s string) Region {
40 r, err := ParseRegion(s)
41 if err != nil {
42 panic(err)
43 }
44 return r
45 }
46
47 // Und is the root language.
48 var Und Tag