<\/span><\/h1>\n\n\n\nBelow is the program illustrating a character constant.<\/p>\n\n\n\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n\ttype myChar int32\n\n\t\/\/Typed character constant\n\tconst aa int32 = 'a'\n\tvar uu = aa\n\tfmt.Println(\"Untyped unnamed character constant\")\n\tfmt.Printf(\"uu: Type: %T Value: %v\\n\\n\", uu, uu)\n\n\t\/\/Below line will raise a compilation error\n\t\/\/var vv myBool = aa\n\n\t\/\/Untyped named character constant\n\tconst bb = 'a'\n\n\tvar ww myChar = bb\n\tvar xx = bb\n\tfmt.Println(\"Untyped named character constant\")\n\tfmt.Printf(\"ww: Type: %T Value: %v\\n\", ww, ww)\n\tfmt.Printf(\"xx: Type: %T Value: %v\\n\\n\", xx, xx)\n\n\t\/\/Untyped unnamed character constant\n\tvar yy myChar = 'a'\n\tvar zz = 'a'\n\tfmt.Println(\"Untyped unnamed character constant\")\n\tfmt.Printf(\"yy: Type: %T Value: %v\\n\", yy, yy)\n\tfmt.Printf(\"zz: Type: %T Value: %v\\n\", zz, zz)\n}<\/code><\/pre>\n\n\n\nOutput:<\/strong><\/p>\n\n\n\nUntyped unnamed character constant\nuu: Type: int32 Value: 97\n\nUntyped named character constant\nww: Type: main.myChar Value: 97\nxx: Type: int32 Value: 97\n\nUntyped unnamed character constant\nyy: Type: main.myChar Value: 97\nzz: Type: int32 Value: 97<\/code><\/pre>\n\n\n\nIn the above program, we created a new type\u00a0 myChar<\/strong><\/p>\n\n\n\ntype myChar int32<\/code><\/pre>\n\n\n\nAlso above program shows the example of<\/p>\n\n\n\n