You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

49 lines
1.2 KiB

  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. package language
  5. // MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed.
  6. // It simplifies safe initialization of Tag values.
  7. func MustParse(s string) Tag {
  8. t, err := Parse(s)
  9. if err != nil {
  10. panic(err)
  11. }
  12. return t
  13. }
  14. // MustParseBase is like ParseBase, but panics if the given base cannot be parsed.
  15. // It simplifies safe initialization of Base values.
  16. func MustParseBase(s string) Language {
  17. b, err := ParseBase(s)
  18. if err != nil {
  19. panic(err)
  20. }
  21. return b
  22. }
  23. // MustParseScript is like ParseScript, but panics if the given script cannot be
  24. // parsed. It simplifies safe initialization of Script values.
  25. func MustParseScript(s string) Script {
  26. scr, err := ParseScript(s)
  27. if err != nil {
  28. panic(err)
  29. }
  30. return scr
  31. }
  32. // MustParseRegion is like ParseRegion, but panics if the given region cannot be
  33. // parsed. It simplifies safe initialization of Region values.
  34. func MustParseRegion(s string) Region {
  35. r, err := ParseRegion(s)
  36. if err != nil {
  37. panic(err)
  38. }
  39. return r
  40. }
  41. // Und is the root language.
  42. var Und Tag