Check language tag

(YoungGopher) #1

Hi! Tell me please how I can current check language tag?
I tried something like this
func main() {

 t, err := language.Parse("en")
 if err != nil {


 k, err := language.ParseBase("en")
 if err != nil {


 r, err := language.ParseRegion("en")
 if err != nil {


But the result is

language: subtag "EN" is well-formed but unknown

and that little confused to me
Which pkg can check tags correctly?

(Norbert Melzer) #2

Where is language coming from? I can not find such a package in the stdlib.

Aside of that, I’m not aware of any language that would have a sub-language “en”, perhaps you should try something like “us” or “uk” there?

(YoungGopher) #3

Sorry, pkg - “
En - I mean like ENG

(Norbert Melzer) #4

I can not find en or eng in the list of valid values per

(YoungGopher) #5

Oh I see, only tags from ISO work’s fine?
But I need check tags with alpha3 value(

(Norbert Melzer) #6

Documentation says this:

ParseRegion parses a 2- or 3-letter ISO 3166-1 or a UN M.49 code. It returns a ValueError if s is a well-formed but unknown region identifier or another error if another error occurred.

So if you have to deal with ISO 639-2, then you need to find a library that can deal with that. Your current library explicitely states it does not.