<\/span><\/h1>\n\n\n\nconst (\n a string = \"circle\"\n b\n)<\/code><\/pre>\n\n\n\nWhen constant type and value is not provided, then it gets its type and value from previous declaration<\/p>\n\n\n\n
a will be of string<\/strong> type with value “circle”<\/strong><\/li><\/ul>\n\n\n\nb will be of type string<\/strong> and value will be “circle”<\/strong><\/li><\/ul>\n\n\n\n<\/span>Combining above two<\/strong><\/span><\/h1>\n\n\n\nconst (\n a string \"circle\"\n b\n c = 1\n)<\/code><\/pre>\n\n\n\na will be of string<\/strong> type with value “circle”<\/strong><\/li><\/ul>\n\n\n\nb will be of type string<\/strong> and value will be “circle”<\/strong><\/li><\/ul>\n\n\n\nc will be of int<\/strong> type with value 1<\/strong><\/li><\/ul>\n\n\n\n<\/span>Multiple declaration in single line<\/strong><\/span><\/h1>\n\n\n\nconst a, b = 1, 2\nconst c, d int = 3, 4<\/code><\/pre>\n\n\n\nDeclaration again can be typed or untyped<\/p>\n\n\n\n
a<\/strong> will be of int<\/strong> type with value 1<\/strong><\/li><\/ul>\n\n\n\nb<\/strong> will be of int<\/strong> type with value 2<\/strong><\/li><\/ul>\n\n\n\nc<\/strong> will be of int<\/strong> type with value 3<\/strong><\/li><\/ul>\n\n\n\nd <\/strong>will be of int<\/strong> type with value 4<\/strong><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"Table of Contents OverviewDeclaring multiple const together with different value and typeDeclaring multiple const together with same value and typeCombining above twoMultiple declaration in single line Overview Below are some of the…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[3,4],"class_list":["post-4140","post","type-post","status-publish","format-standard","hentry","category-tech","tag-go","tag-golang"],"yoast_head":"\n
Multiple constant declarations in Go (Golang) - Welcome To Golang By Example<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n