{"id":108,"date":"2026-03-28T09:00:00","date_gmt":"2026-03-28T03:30:00","guid":{"rendered":"https:\/\/smitabharat.com\/blog\/?p=108"},"modified":"2026-10-10T21:20:33","modified_gmt":"2026-10-10T15:50:33","slug":"go-variables-constants-data-types","status":"publish","type":"post","link":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/","title":{"rendered":"Go Variables, Constants and Data Types Explained Simply"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Go variables are the first thing you need after setting up Go, because every program stores some data. In this post, you will learn how to create variables and constants. You will also meet the data types you use every day. Each idea comes with a small example you can run.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are new to the language, start with my guide on <a href=\"https:\/\/smitabharat.com\/blog\/what-is-go-lang\/\">what Go is and where it is used<\/a>. Also, these topics come up in almost every interview, so my <a href=\"https:\/\/smitabharat.com\/blog\/go-lang-interview-questions-and-answers\/\">Go interview questions and answers<\/a> page is good practice later.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Are Go Variables?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A variable is a named box that holds a value. Think of a labelled jar in your kitchen. The label is the name, and the sugar inside is the value. You can open the jar later and use what is inside.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Go is a statically typed language. This means every box has a fixed type, such as number or text. So a box made for numbers can never hold text. This rule catches many bugs before your program even runs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Declare Go Variables<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To declare a variable means to create it and give it a name. Go gives you two main ways to do this.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using the var Keyword<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>var name string = \"Smita\"\nvar age int = 30\n\nfmt.Println(name, age) \/\/ Smita 30<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">First comes the word <code>var<\/code>, then the name, then the type, and finally the value. This form works everywhere, both inside and outside functions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using the Short Form :=<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>city := \"Pune\"\nprice := 99.50\nisActive := true\n\nfmt.Println(city, price, isActive) \/\/ Pune 99.5 true<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here you skip both <code>var<\/code> and the type. Instead, Go looks at the value and picks the type for you. We call this type inference. Most Go developers use this short form inside functions, because it is quick to write.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Declaring Many Go Variables at Once<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>var (\n\tfirstName = \"Asha\"\n\tscore     = 85\n)\n\nx, y := 10, 20<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>var ( )<\/code> block groups related values together, so your code stays tidy. Also, the second line shows how to create two Go variables in one step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Zero Values: What Go Variables Hold by Default<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">What happens if you create a variable but give it no value? In many languages, you get garbage or an error. However, Go fills it with a safe starting value called the zero value.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var count int\nvar total float64\nvar title string\nvar done bool\n\nfmt.Println(count, total, title, done) \/\/ 0 0  false<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Type<\/th><th>Zero value<\/th><\/tr><\/thead><tbody><tr><td>int, float64<\/td><td>0<\/td><\/tr><tr><td>string<\/td><td>&#8220;&#8221; (empty text)<\/td><\/tr><tr><td>bool<\/td><td>false<\/td><\/tr><tr><td>pointer, slice, map<\/td><td>nil (nothing yet)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Notice the two spaces in the output. That gap is the empty string sitting between 0 and false.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Data Types in Go<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A data type tells Go what kind of value a box can hold. Here are the types you will use most of the time.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Type<\/th><th>Holds<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td>int<\/td><td>Whole numbers<\/td><td>30, -7<\/td><\/tr><tr><td>float64<\/td><td>Decimal numbers<\/td><td>99.50<\/td><\/tr><tr><td>string<\/td><td>Text<\/td><td>&#8220;Pune&#8221;<\/td><\/tr><tr><td>bool<\/td><td>True or false<\/td><td>true<\/td><\/tr><tr><td>byte<\/td><td>One byte of data (same as uint8)<\/td><td>&#8216;A&#8217;<\/td><\/tr><tr><td>rune<\/td><td>One Unicode character (same as int32)<\/td><td>&#8216;\u20b9&#8217;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-diagram-1024x640.png\" alt=\"Go Variables diagram showing long form, short form and zero values for each type\" class=\"wp-image-109\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-diagram-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-diagram-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-diagram-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-diagram.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Every variable has a name, a type and a value. Each type also has its own zero value.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Want to check a type yourself? Use <code>%T<\/code> with <code>fmt.Printf<\/code>, and Go prints the type name.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fmt.Printf(\"%T %T %T\\n\", city, price, isActive)\n\/\/ string float64 bool<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Type Conversion<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Go never mixes types on its own. So if you add an int to a float64, you must convert one of them first.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apples := 5\nweight := 2.75\n\nsum := float64(apples) + weight\nfmt.Println(sum)         \/\/ 7.75\nfmt.Println(int(weight)) \/\/ 2\n\ntext := \"Count: \" + strconv.Itoa(apples)\nfmt.Println(text)        \/\/ Count: 5<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Look at <code>int(weight)<\/code>. It cuts off the decimal part, so 2.75 becomes 2. Also, to turn a number into text, use <code>strconv.Itoa<\/code> from the strconv package.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Constants in Go<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A constant is a value that never changes, like the number of days in a week. You create it with <code>const<\/code> instead of <code>var<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const Pi = 3.14\n\nconst (\n\tSmall = iota \/\/ 0\n\tMedium       \/\/ 1\n\tLarge        \/\/ 2\n)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The word <code>iota<\/code> is a counter that starts at 0. Then it goes up by one on each new line inside the block. This is handy for sizes, levels or status codes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you try <code>Pi = 3.15<\/code> later, the compiler stops with an error. That is the whole point, because a constant protects values that must stay fixed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Go Variables<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error you see<\/th><th>Why it happens<\/th><th>How to fix it<\/th><\/tr><\/thead><tbody><tr><td>declared and not used: unused<\/td><td>You created a local variable but never used it.<\/td><td>Use the variable or delete it.<\/td><\/tr><tr><td>syntax error: non-declaration statement outside function body<\/td><td>You used := outside a function.<\/td><td>Use var at package level.<\/td><\/tr><tr><td>invalid operation: mismatched types int and float64<\/td><td>You mixed two number types.<\/td><td>Convert one side, for example float64(x).<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The first error surprises most beginners. Still, it is a good habit, because unused Go variables usually point to a bug. One more tip: names starting with a capital letter, like <code>Total<\/code>, are visible to other packages. Lowercase names stay private.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These pages come straight from the Go team, so they are always correct.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/go.dev\/tour\/basics\/8\">A Tour of Go: Variables<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/go.dev\/ref\/spec#Constants\">Go spec: Constants<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/go.dev\/ref\/spec#The_zero_value\">Go spec: The zero value<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pkg.go.dev\/strconv\">strconv package documentation<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go variables are named boxes with a fixed type and a value.<\/li>\n\n\n\n<li>Use var anywhere, and the short form := inside functions.<\/li>\n\n\n\n<li>A variable with no value gets a zero value: 0, &#8220;&#8221;, false or nil.<\/li>\n\n\n\n<li>Go never mixes types, so convert with float64(x), int(y) or strconv.Itoa.<\/li>\n\n\n\n<li>Constants use const and cannot change, and iota counts up from 0.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now you can store data in Go. Next, we will use that data with operators, so you can add, compare and combine values.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Coming soon: Go Operators with Simple Examples<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Later in this series, you will save these values in a real database. If you are curious, my <a href=\"https:\/\/smitabharat.com\/blog\/database-interview-questions\/\">database interview questions<\/a> post explains tables, keys and joins.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go variables are the first thing you need after setting up Go, because every program stores some data. In this post, you will learn&hellip;<\/p>\n","protected":false},"author":1,"featured_media":110,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[15],"tags":[11,23,24,21],"swapz_series":[],"class_list":["post-108","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go-lang","tag-go-lang","tag-go-tutorial","tag-go-variables","tag-golang-basics"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Go Variables, Constants and Data Types for Beginners<\/title>\n<meta name=\"description\" content=\"Learn Go variables, constants and data types with simple examples: var, :=, zero values, type conversion and iota.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go Variables, Constants and Data Types for Beginners\" \/>\n<meta property=\"og:description\" content=\"Learn Go variables, constants and data types with simple examples: var, :=, zero values, type conversion and iota.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/\" \/>\n<meta property=\"og:site_name\" content=\"Smita Bharat - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-28T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-10T15:50:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Smita\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Smita\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/\"},\"author\":{\"name\":\"Smita\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"headline\":\"Go Variables, Constants and Data Types Explained Simply\",\"datePublished\":\"2026-03-28T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:50:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/\"},\"wordCount\":870,\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-variables-constants-data-types-featured.png\",\"keywords\":[\"Go Lang\",\"Go Tutorial\",\"Go Variables\",\"Golang Basics\"],\"articleSection\":[\"Go Lang\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/\",\"name\":\"Go Variables, Constants and Data Types for Beginners\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-variables-constants-data-types-featured.png\",\"datePublished\":\"2026-03-28T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:50:33+00:00\",\"description\":\"Learn Go variables, constants and data types with simple examples: var, :=, zero values, type conversion and iota.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/#primaryimage\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-variables-constants-data-types-featured.png\",\"contentUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-variables-constants-data-types-featured.png\",\"width\":1200,\"height\":630,\"caption\":\"Go Variables featured image: cards showing var, := and const with name, type and value\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-variables-constants-data-types\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go Variables, Constants and Data Types Explained Simply\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\",\"name\":\"Smita Bharat Blog\",\"description\":\"Golang &amp; Backend Development Tutorials and Interview Questions\",\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"alternateName\":\"Smita Bharat\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\",\"name\":\"Smita\",\"logo\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/smitabharat.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go Variables, Constants and Data Types for Beginners","description":"Learn Go variables, constants and data types with simple examples: var, :=, zero values, type conversion and iota.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/","og_locale":"en_US","og_type":"article","og_title":"Go Variables, Constants and Data Types for Beginners","og_description":"Learn Go variables, constants and data types with simple examples: var, :=, zero values, type conversion and iota.","og_url":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/","og_site_name":"Smita Bharat - Blog","article_published_time":"2026-03-28T03:30:00+00:00","article_modified_time":"2026-10-10T15:50:33+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-featured.png","type":"image\/png"}],"author":"Smita","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Smita","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/#article","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/"},"author":{"name":"Smita","@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"headline":"Go Variables, Constants and Data Types Explained Simply","datePublished":"2026-03-28T03:30:00+00:00","dateModified":"2026-10-10T15:50:33+00:00","mainEntityOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/"},"wordCount":870,"publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-featured.png","keywords":["Go Lang","Go Tutorial","Go Variables","Golang Basics"],"articleSection":["Go Lang"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/","url":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/","name":"Go Variables, Constants and Data Types for Beginners","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/#primaryimage"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-featured.png","datePublished":"2026-03-28T03:30:00+00:00","dateModified":"2026-10-10T15:50:33+00:00","description":"Learn Go variables, constants and data types with simple examples: var, :=, zero values, type conversion and iota.","breadcrumb":{"@id":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/#primaryimage","url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-featured.png","contentUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-variables-constants-data-types-featured.png","width":1200,"height":630,"caption":"Go Variables featured image: cards showing var, := and const with name, type and value"},{"@type":"BreadcrumbList","@id":"https:\/\/smitabharat.com\/blog\/go-variables-constants-data-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smitabharat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go Variables, Constants and Data Types Explained Simply"}]},{"@type":"WebSite","@id":"https:\/\/smitabharat.com\/blog\/#website","url":"https:\/\/smitabharat.com\/blog\/","name":"Smita Bharat Blog","description":"Golang &amp; Backend Development Tutorials and Interview Questions","publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"alternateName":"Smita Bharat","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smitabharat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339","name":"Smita","logo":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/smitabharat.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":1,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":111,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions\/111"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media\/110"}],"wp:attachment":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/tags?post=108"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}