{"id":154,"date":"2026-07-07T20:21:02","date_gmt":"2026-07-07T20:21:02","guid":{"rendered":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/"},"modified":"2026-07-07T20:38:00","modified_gmt":"2026-07-07T20:38:00","slug":"03-go-basic-syntax","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/","title":{"rendered":"Go Basic Syntax \u2013 Structure of a Go Program"},"content":{"rendered":"<p><!-- ktg-updated-banner --><\/p>\n<div class=\"ktg-updated-banner\" style=\"margin:0 0 1.25em;padding:0.75em 1em;background:#fefce8;border-left:4px solid #ca8a04;border-radius:4px;\">\n<p><strong>Updated July 2, 2026.<\/strong> Refreshed for Go 1.22+ and current SEO best practices.<\/p>\n<\/div>\n<p><!-- ktg-go-modern --><\/p>\n<div class=\"ktg-go-modern\" style=\"margin:1.5em 0;padding:1em;background:#eff6ff;border-left:4px solid #2563eb;border-radius:4px;\">\n<h4>Go 1.22+ Notes<\/h4>\n<p>Run <code>go fmt .\/...<\/code> after editing any lesson code. Go 1.22+ uses the same basic syntax shown here \u2014 packages, <code>func main<\/code>, and the standard library remain the foundation for backend and cloud-native projects.<\/p>\n<\/div>\n<p>In this lesson we cover <strong>Go basic syntax<\/strong> \u2014 the building blocks every Go program shares. If you completed <a href=\"https:\/\/www.kindsonthegenius.com\/go\/go-programming-setup\/\">Go Programming \u2013 Setup<\/a>, you already ran your first program. Here we explain <em>why<\/em> that program looks the way it does and the rules you must follow when writing Go code.<\/p>\n<p><strong>Prerequisites:<\/strong> Go 1.22 or newer installed (<code>go version<\/code> in your terminal). <strong>Estimated time:<\/strong> 30\u201340 minutes.<\/p>\n<h4 id=\"structure\">1. Structure of a Go Program<\/h4>\n<p>Every executable Go program has the same skeleton: a <code>package<\/code> declaration, <code>import<\/code> statements, and a <code>main<\/code> function. Consider this program (the same one from the Setup lesson):<\/p>\n<pre><code class=\"language-go\">package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"Welcome to Go!\")\n}\n<\/code><\/pre>\n<p>Let us walk through it line by line:<\/p>\n<ul>\n<li><code>package main<\/code> \u2014 Declares that this file belongs to the <code>main<\/code> package. Programs that compile to an executable must use <code>package main<\/code>.<\/li>\n<li><code>import \"fmt\"<\/code> \u2014 Brings in the <code>fmt<\/code> (formatting) standard library so we can print to the console.<\/li>\n<li><code>func main()<\/code> \u2014 The entry point. Execution starts here when you run the program.<\/li>\n<li><code>fmt.Println(...)<\/code> \u2014 Calls the <code>Println<\/code> function from <code>fmt<\/code> and prints a line of text.<\/li>\n<\/ul>\n<p>Go source files use the <code>.go<\/code> extension. A small project might live in a single file; larger projects split code across many files in the same package or across multiple packages inside a module (created with <code>go mod init<\/code>).<\/p>\n<h4 id=\"comments\">2. Comments in Go<\/h4>\n<p>Comments are notes for humans \u2014 the compiler ignores them. Go supports two styles:<\/p>\n<pre><code class=\"language-go\">\/\/ This is a single-line comment\n\n\/*\n   This is a\n   multi-line comment\n*\/\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\t\/\/ Print a greeting\n\tfmt.Println(\"Hello, Kindson The Genius!\")\n}\n<\/code><\/pre>\n<p>Use comments to document your name, the date, and what the program does \u2014 especially in learning exercises.<\/p>\n<h4 id=\"identifiers\">3. Identifiers and Naming Rules<\/h4>\n<p>An <strong>identifier<\/strong> is a name you give to a variable, function, type, or package. In Go, identifiers must:<\/p>\n<ul>\n<li>Start with a letter or underscore (<code>_<\/code>)<\/li>\n<li>Contain only letters, digits, and underscores after the first character<\/li>\n<li>Not use special characters such as <code>$<\/code>, <code>@<\/code>, or spaces<\/li>\n<\/ul>\n<p><strong>Exported vs unexported:<\/strong> If an identifier starts with an <strong>uppercase<\/strong> letter, it is exported (visible outside its package). Lowercase names are private to the package. For example, <code>Println<\/code> is exported from <code>fmt<\/code>; an unexported helper might be named <code>println<\/code>.<\/p>\n<p>Valid identifiers: <code>name<\/code>, <code>userID<\/code>, <code>_temp<\/code>, <code>MaxRetries<\/code><br \/>\nInvalid identifiers: <code>2fast<\/code>, <code>user-name<\/code>, <code>go!<\/code><\/p>\n<h4 id=\"keywords\">4. Go Reserved Words (Keywords)<\/h4>\n<p>Keywords are reserved by the language \u2014 you cannot use them as identifier names. Go has 25 keywords:<\/p>\n<table>\n<thead>\n<tr>\n<th>Keywords<\/th>\n<th>Keywords<\/th>\n<th>Keywords<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>break<\/code><\/td>\n<td><code>default<\/code><\/td>\n<td><code>func<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>interface<\/code><\/td>\n<td><code>select<\/code><\/td>\n<td><code>case<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>defer<\/code><\/td>\n<td><code>go<\/code><\/td>\n<td><code>struct<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>chan<\/code><\/td>\n<td><code>else<\/code><\/td>\n<td><code>goto<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>map<\/code><\/td>\n<td><code>switch<\/code><\/td>\n<td><code>const<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>fallthrough<\/code><\/td>\n<td><code>if<\/code><\/td>\n<td><code>range<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>type<\/code><\/td>\n<td><code>continue<\/code><\/td>\n<td><code>for<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>import<\/code><\/td>\n<td><code>package<\/code><\/td>\n<td><code>var<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Notice keywords like <code>go<\/code>, <code>defer<\/code>, <code>select<\/code>, and <code>range<\/code> \u2014 they support Go&#8217;s concurrency and iteration features you will meet in later lessons.<\/p>\n<h4 id=\"blocks\">5. Code Blocks and Braces<\/h4>\n<p>Unlike Python, Go uses <strong>curly braces<\/strong> <code>{ }<\/code> to define blocks of code \u2014 not indentation alone. However, consistent indentation (tabs are standard) makes code readable.<\/p>\n<pre><code class=\"language-go\">func main() {\n\tif true {\n\t\tfmt.Println(\"Inside the if block\")\n\t}\n}\n<\/code><\/pre>\n<p>Every opening brace <code>{<\/code> must have a matching closing brace <code>}<\/code>. Go automatically inserts semicolons at the end of lines during compilation, so you rarely type <code>;<\/code> yourself \u2014 but statements are still logically terminated.<\/p>\n<h4 id=\"whitespace\">6. Whitespace and Formatting with gofmt<\/h4>\n<p>Go treats extra spaces, blank lines, and tabs mostly as separators \u2014 but style matters for readability. The Go toolchain includes <strong>gofmt<\/strong> (or <code>go fmt<\/code>), which formats code to a community standard:<\/p>\n<pre><code class=\"language-bash\">go fmt main.go\n# or format all files in the current directory:\ngo fmt .\/...\n<\/code><\/pre>\n<p>Most editors \u2014 including VS Code with the Go extension and GoLand \u2014 run <code>gofmt<\/code> on save. This is why Go code across projects looks consistent.<\/p>\n<h4 id=\"running\">7. Running Your Program<\/h4>\n<p>From the Setup lesson you ran code inside GoLand. From the terminal, inside your project folder:<\/p>\n<pre><code class=\"language-bash\"># Compile and run in one step (great while learning)\ngo run .\n\n# Build an executable binary\ngo build -o myapp .\n.\/myapp\n<\/code><\/pre>\n<p><code>go run<\/code> is ideal for quick experiments. <code>go build<\/code> produces a standalone binary you can deploy \u2014 one reason Go is popular for servers and DevOps tools.<\/p>\n<h4 id=\"next\">8. Next Steps<\/h4>\n<p>You now understand <strong>Go basic syntax<\/strong>: packages, imports, <code>func main<\/code>, comments, identifiers, keywords, and blocks. In the next lesson we cover <strong>variables and data types<\/strong> \u2014 how to store and work with values in Go.<\/p>\n<p>Continue the series: <a href=\"https:\/\/www.kindsonthegenius.com\/go\/go-programming-introduction\/\">Lesson 1 \u2013 Introduction<\/a> \u00b7 <a href=\"https:\/\/www.kindsonthegenius.com\/go\/go-programming-setup\/\">Lesson 2 \u2013 Setup<\/a><\/p>\n<h4 id=\"faq\">Frequently Asked Questions<\/h4>\n<p><strong>What is the basic structure of a Go program?<\/strong><br \/>\nA Go program starts with <code>package main<\/code>, imports the packages it needs, and defines <code>func main()<\/code> where execution begins.<\/p>\n<p><strong>Does Go require semicolons?<\/strong><br \/>\nGo inserts semicolons automatically at line endings during compilation. You almost never write them manually.<\/p>\n<p><strong>What is the difference between go run and go build?<\/strong><br \/>\n<code>go run<\/code> compiles and executes immediately without leaving a binary file. <code>go build<\/code> creates an executable you can run or ship separately.<\/p>\n<p><!-- ktg-lesson-nav --><\/p>\n<nav class=\"ktg-lesson-nav\" aria-label=\"Lesson navigation\">\n<p><strong>Previous:<\/strong> <a href=\"https:\/\/kindsonthegenius.com\/go\/2021\/01\/21\/go-programming-setup\/\">Lesson 2: Go Programming &#8211; Setup<\/a><\/p>\n<p><strong>Next:<\/strong> <a href=\"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/04-go-variables-and-types\/\">Lesson 4: Go Variables and Types \u2013 Storing Data in Go<\/a><\/p>\n<\/nav>\n<p><!-- ktg-alkademy-cta --><\/p>\n<div class=\"ktg-alkademy-cta\" style=\"margin:2em 0;padding:1.25em;border-left:4px solid #2563eb;background:#f8fafc;\">\n<p><strong>Want live Go or backend classes?<\/strong> Join <a href=\"https:\/\/www.alkademy.com\/courses\" target=\"_blank\" rel=\"noopener noreferrer\">Alkademy<\/a> for instructor-led programming courses with hands-on projects.<\/p>\n<\/div>\n<p><!-- ktg-faq-schema --><br \/>\n<script type=\"application\/ld+json\">{\"@context\":\"https:\/\/schema.org\",\"@type\":\"FAQPage\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"What is the basic structure of a Go program?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"A Go program starts with package main, imports needed packages, and defines func main() where execution begins.\"}},{\"@type\":\"Question\",\"name\":\"Does Go require semicolons?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Go inserts semicolons automatically at line endings. You rarely write them.\"}},{\"@type\":\"Question\",\"name\":\"What is the difference between go run and go build?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"go run compiles and executes immediately. go build creates a binary you can ship.\"}}]}<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Updated July 2, 2026. Refreshed for Go 1.22+ and current SEO best practices. Go 1.22+ Notes Run go fmt .\/&#8230; after editing any lesson code. &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[23],"tags":[],"class_list":["post-154","post","type-post","status-publish","format-standard","hentry","category-go-programming"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"Updated July 2, 2026. Refreshed for Go 1.22+ and current SEO best practices. Go 1.22+ Notes Run go fmt .\/... after editing any lesson code. Go 1.22+ uses the same basic syntax shown here \u2014 packages, func main, and the standard library remain the foundation for backend and cloud-native projects. In this lesson we cover\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"kindsonthegenius\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Go Programming Tutorial - Beginner to Expert Go Programming Tutorial\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Go Basic Syntax \u2013 Structure of a Go Program - Go Programming Tutorial\" \/>\n\t\t<meta property=\"og:description\" content=\"Updated July 2, 2026. Refreshed for Go 1.22+ and current SEO best practices. Go 1.22+ Notes Run go fmt .\/... after editing any lesson code. Go 1.22+ uses the same basic syntax shown here \u2014 packages, func main, and the standard library remain the foundation for backend and cloud-native projects. In this lesson we cover\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2026-07-07T20:21:02+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2026-07-07T20:38:00+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Go Basic Syntax \u2013 Structure of a Go Program - Go Programming Tutorial\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Updated July 2, 2026. Refreshed for Go 1.22+ and current SEO best practices. Go 1.22+ Notes Run go fmt .\/... after editing any lesson code. Go 1.22+ uses the same basic syntax shown here \u2014 packages, func main, and the standard library remain the foundation for backend and cloud-native projects. In this lesson we cover\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#blogposting\",\"name\":\"Go Basic Syntax \\u2013 Structure of a Go Program - Go Programming Tutorial\",\"headline\":\"Go Basic Syntax \\u2013 Structure of a Go Program\",\"author\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/author\\\/kindsonthegenius-3\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/#organization\"},\"datePublished\":\"2026-07-07T20:21:02+00:00\",\"dateModified\":\"2026-07-07T20:38:00+00:00\",\"inLanguage\":\"en-US\",\"commentCount\":1,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#webpage\"},\"articleSection\":\"Go Programming\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/category\\\/go-programming\\\/#listItem\",\"name\":\"Go Programming\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/category\\\/go-programming\\\/#listItem\",\"position\":2,\"name\":\"Go Programming\",\"item\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/category\\\/go-programming\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#listItem\",\"name\":\"Go Basic Syntax \\u2013 Structure of a Go Program\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#listItem\",\"position\":3,\"name\":\"Go Basic Syntax \\u2013 Structure of a Go Program\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/category\\\/go-programming\\\/#listItem\",\"name\":\"Go Programming\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/#organization\",\"name\":\"Go Programming Tutorial\",\"description\":\"Beginner to Expert Go Programming Tutorial\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/author\\\/kindsonthegenius-3\\\/#author\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/author\\\/kindsonthegenius-3\\\/\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"kindsonthegenius\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#webpage\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/\",\"name\":\"Go Basic Syntax \\u2013 Structure of a Go Program - Go Programming Tutorial\",\"description\":\"Updated July 2, 2026. Refreshed for Go 1.22+ and current SEO best practices. Go 1.22+ Notes Run go fmt .\\\/... after editing any lesson code. Go 1.22+ uses the same basic syntax shown here \\u2014 packages, func main, and the standard library remain the foundation for backend and cloud-native projects. In this lesson we cover\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/author\\\/kindsonthegenius-3\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/author\\\/kindsonthegenius-3\\\/#author\"},\"datePublished\":\"2026-07-07T20:21:02+00:00\",\"dateModified\":\"2026-07-07T20:38:00+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/#website\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/\",\"name\":\"Go Programming Tutorial\",\"description\":\"Beginner to Expert Go Programming Tutorial\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Go Basic Syntax \u2013 Structure of a Go Program - Go Programming Tutorial","description":"Updated July 2, 2026. Refreshed for Go 1.22+ and current SEO best practices. Go 1.22+ Notes Run go fmt .\/... after editing any lesson code. Go 1.22+ uses the same basic syntax shown here \u2014 packages, func main, and the standard library remain the foundation for backend and cloud-native projects. In this lesson we cover","canonical_url":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#blogposting","name":"Go Basic Syntax \u2013 Structure of a Go Program - Go Programming Tutorial","headline":"Go Basic Syntax \u2013 Structure of a Go Program","author":{"@id":"https:\/\/kindsonthegenius.com\/go\/author\/kindsonthegenius-3\/#author"},"publisher":{"@id":"https:\/\/kindsonthegenius.com\/go\/#organization"},"datePublished":"2026-07-07T20:21:02+00:00","dateModified":"2026-07-07T20:38:00+00:00","inLanguage":"en-US","commentCount":1,"mainEntityOfPage":{"@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#webpage"},"isPartOf":{"@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#webpage"},"articleSection":"Go Programming"},{"@type":"BreadcrumbList","@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/kindsonthegenius.com\/go#listItem","position":1,"name":"Home","item":"https:\/\/kindsonthegenius.com\/go","nextItem":{"@type":"ListItem","@id":"https:\/\/kindsonthegenius.com\/go\/category\/go-programming\/#listItem","name":"Go Programming"}},{"@type":"ListItem","@id":"https:\/\/kindsonthegenius.com\/go\/category\/go-programming\/#listItem","position":2,"name":"Go Programming","item":"https:\/\/kindsonthegenius.com\/go\/category\/go-programming\/","nextItem":{"@type":"ListItem","@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#listItem","name":"Go Basic Syntax \u2013 Structure of a Go Program"},"previousItem":{"@type":"ListItem","@id":"https:\/\/kindsonthegenius.com\/go#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#listItem","position":3,"name":"Go Basic Syntax \u2013 Structure of a Go Program","previousItem":{"@type":"ListItem","@id":"https:\/\/kindsonthegenius.com\/go\/category\/go-programming\/#listItem","name":"Go Programming"}}]},{"@type":"Organization","@id":"https:\/\/kindsonthegenius.com\/go\/#organization","name":"Go Programming Tutorial","description":"Beginner to Expert Go Programming Tutorial","url":"https:\/\/kindsonthegenius.com\/go\/"},{"@type":"Person","@id":"https:\/\/kindsonthegenius.com\/go\/author\/kindsonthegenius-3\/#author","url":"https:\/\/kindsonthegenius.com\/go\/author\/kindsonthegenius-3\/","name":"kindsonthegenius","image":{"@type":"ImageObject","@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","width":96,"height":96,"caption":"kindsonthegenius"}},{"@type":"WebPage","@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#webpage","url":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/","name":"Go Basic Syntax \u2013 Structure of a Go Program - Go Programming Tutorial","description":"Updated July 2, 2026. Refreshed for Go 1.22+ and current SEO best practices. Go 1.22+ Notes Run go fmt .\/... after editing any lesson code. Go 1.22+ uses the same basic syntax shown here \u2014 packages, func main, and the standard library remain the foundation for backend and cloud-native projects. In this lesson we cover","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/kindsonthegenius.com\/go\/#website"},"breadcrumb":{"@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#breadcrumblist"},"author":{"@id":"https:\/\/kindsonthegenius.com\/go\/author\/kindsonthegenius-3\/#author"},"creator":{"@id":"https:\/\/kindsonthegenius.com\/go\/author\/kindsonthegenius-3\/#author"},"datePublished":"2026-07-07T20:21:02+00:00","dateModified":"2026-07-07T20:38:00+00:00"},{"@type":"WebSite","@id":"https:\/\/kindsonthegenius.com\/go\/#website","url":"https:\/\/kindsonthegenius.com\/go\/","name":"Go Programming Tutorial","description":"Beginner to Expert Go Programming Tutorial","inLanguage":"en-US","publisher":{"@id":"https:\/\/kindsonthegenius.com\/go\/#organization"}}]},"og:locale":"en_US","og:site_name":"Go Programming Tutorial - Beginner to Expert Go Programming Tutorial","og:type":"article","og:title":"Go Basic Syntax \u2013 Structure of a Go Program - Go Programming Tutorial","og:description":"Updated July 2, 2026. Refreshed for Go 1.22+ and current SEO best practices. Go 1.22+ Notes Run go fmt .\/... after editing any lesson code. Go 1.22+ uses the same basic syntax shown here \u2014 packages, func main, and the standard library remain the foundation for backend and cloud-native projects. In this lesson we cover","og:url":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/","article:published_time":"2026-07-07T20:21:02+00:00","article:modified_time":"2026-07-07T20:38:00+00:00","twitter:card":"summary_large_image","twitter:title":"Go Basic Syntax \u2013 Structure of a Go Program - Go Programming Tutorial","twitter:description":"Updated July 2, 2026. Refreshed for Go 1.22+ and current SEO best practices. Go 1.22+ Notes Run go fmt .\/... after editing any lesson code. Go 1.22+ uses the same basic syntax shown here \u2014 packages, func main, and the standard library remain the foundation for backend and cloud-native projects. In this lesson we cover"},"aioseo_meta_data":[],"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/kindsonthegenius.com\/go\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/kindsonthegenius.com\/go\/category\/go-programming\/\" title=\"Go Programming\">Go Programming<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tGo Basic Syntax \u2013 Structure of a Go Program\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/kindsonthegenius.com\/go"},{"label":"Go Programming","link":"https:\/\/kindsonthegenius.com\/go\/category\/go-programming\/"},{"label":"Go Basic Syntax \u2013 Structure of a Go Program","link":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/"}],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Go Basic Syntax \u2013 Structure of a Go Program | Go Programming Tutorial<\/title>\n<meta name=\"description\" content=\"Learn Go basic syntax \u2014 package, import, func main, comments, identifiers, and keywords. Lesson 3 in the free Go tutorial with runnable examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go Basic Syntax \u2013 Structure of a Go Program | Go Programming Tutorial\" \/>\n<meta property=\"og:description\" content=\"Learn Go basic syntax \u2014 package, import, func main, comments, identifiers, and keywords. Lesson 3 in the free Go tutorial with runnable examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/\" \/>\n<meta property=\"og:site_name\" content=\"Go Programming Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-07T20:21:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-07T20:38:00+00:00\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/#\\\/schema\\\/person\\\/1b5971e6d80495780d9857f155fd1b21\"},\"headline\":\"Go Basic Syntax \u2013 Structure of a Go Program\",\"datePublished\":\"2026-07-07T20:21:02+00:00\",\"dateModified\":\"2026-07-07T20:38:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/\"},\"wordCount\":689,\"commentCount\":1,\"articleSection\":[\"Go Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/\",\"name\":\"Go Basic Syntax \u2013 Structure of a Go Program | Go Programming Tutorial\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/#website\"},\"datePublished\":\"2026-07-07T20:21:02+00:00\",\"dateModified\":\"2026-07-07T20:38:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/#\\\/schema\\\/person\\\/1b5971e6d80495780d9857f155fd1b21\"},\"description\":\"Learn Go basic syntax \u2014 package, import, func main, comments, identifiers, and keywords. Lesson 3 in the free Go tutorial with runnable examples.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/2026\\\/07\\\/07\\\/03-go-basic-syntax\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go Basic Syntax \u2013 Structure of a Go Program\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/#website\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/\",\"name\":\"Go Programming Tutorial\",\"description\":\"Beginner to Expert Go Programming Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/#\\\/schema\\\/person\\\/1b5971e6d80495780d9857f155fd1b21\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/go\\\/author\\\/kindsonthegenius-3\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go Basic Syntax \u2013 Structure of a Go Program | Go Programming Tutorial","description":"Learn Go basic syntax \u2014 package, import, func main, comments, identifiers, and keywords. Lesson 3 in the free Go tutorial with runnable examples.","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:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/","og_locale":"en_US","og_type":"article","og_title":"Go Basic Syntax \u2013 Structure of a Go Program | Go Programming Tutorial","og_description":"Learn Go basic syntax \u2014 package, import, func main, comments, identifiers, and keywords. Lesson 3 in the free Go tutorial with runnable examples.","og_url":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/","og_site_name":"Go Programming Tutorial","article_published_time":"2026-07-07T20:21:02+00:00","article_modified_time":"2026-07-07T20:38:00+00:00","author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#article","isPartOf":{"@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/kindsonthegenius.com\/go\/#\/schema\/person\/1b5971e6d80495780d9857f155fd1b21"},"headline":"Go Basic Syntax \u2013 Structure of a Go Program","datePublished":"2026-07-07T20:21:02+00:00","dateModified":"2026-07-07T20:38:00+00:00","mainEntityOfPage":{"@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/"},"wordCount":689,"commentCount":1,"articleSection":["Go Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/","url":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/","name":"Go Basic Syntax \u2013 Structure of a Go Program | Go Programming Tutorial","isPartOf":{"@id":"https:\/\/kindsonthegenius.com\/go\/#website"},"datePublished":"2026-07-07T20:21:02+00:00","dateModified":"2026-07-07T20:38:00+00:00","author":{"@id":"https:\/\/kindsonthegenius.com\/go\/#\/schema\/person\/1b5971e6d80495780d9857f155fd1b21"},"description":"Learn Go basic syntax \u2014 package, import, func main, comments, identifiers, and keywords. Lesson 3 in the free Go tutorial with runnable examples.","breadcrumb":{"@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kindsonthegenius.com\/go\/2026\/07\/07\/03-go-basic-syntax\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kindsonthegenius.com\/go\/"},{"@type":"ListItem","position":2,"name":"Go Basic Syntax \u2013 Structure of a Go Program"}]},{"@type":"WebSite","@id":"https:\/\/kindsonthegenius.com\/go\/#website","url":"https:\/\/kindsonthegenius.com\/go\/","name":"Go Programming Tutorial","description":"Beginner to Expert Go Programming Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kindsonthegenius.com\/go\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/kindsonthegenius.com\/go\/#\/schema\/person\/1b5971e6d80495780d9857f155fd1b21","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/kindsonthegenius.com\/go\/author\/kindsonthegenius-3\/"}]}},"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/go\/wp-json\/wp\/v2\/posts\/154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/go\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/go\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/go\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/go\/wp-json\/wp\/v2\/comments?post=154"}],"version-history":[{"count":3,"href":"https:\/\/kindsonthegenius.com\/go\/wp-json\/wp\/v2\/posts\/154\/revisions"}],"predecessor-version":[{"id":188,"href":"https:\/\/kindsonthegenius.com\/go\/wp-json\/wp\/v2\/posts\/154\/revisions\/188"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/go\/wp-json\/wp\/v2\/media?parent=154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/go\/wp-json\/wp\/v2\/categories?post=154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/go\/wp-json\/wp\/v2\/tags?post=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}