blob: e7afd3188e6abe6e1c2ac93e07411d97df47c0a7 [file] [log] [blame]
Don Newton98fd8812019-09-23 15:15:02 -04001// 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
5package 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.
9func 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.
19func 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.
29func 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.
39func 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.
48var Und Tag