{"id":7485,"date":"2021-03-22T13:37:48","date_gmt":"2021-03-22T13:37:48","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=7485"},"modified":"2024-04-15T07:34:58","modified_gmt":"2024-04-15T07:34:58","slug":"structs-in-golang-structures-in-golang","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/","title":{"rendered":"Structs in Golang"},"content":{"rendered":"\r\n<h2><span data-sheets-root=\"1\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Structures in Golang&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:513,&quot;3&quot;:{&quot;1&quot;:0},&quot;12&quot;:0}\">Structures in Golang<\/span><\/h2>\r\n<p>&nbsp;<\/p>\r\n<p>In Go (Golang), structures, also known as structs, are a fundamental composite data type use to define custom data structures with fields. Structs allow developers to encapsulate related data fields into a single entity, providing a way to organize and manage data more effectively.<\/p>\r\n<p>A struct in Go is defined using the <code>type<\/code> keyword followed by the <code>struct<\/code> keyword and a set of field declarations enclosed in curly braces <code>{}<\/code>. Each field within a struct is define with a name and a data type, representing a specific piece of data associate with the struct.<\/p>\r\n<p>Structs can be use to model real-world entities or abstract data concepts by grouping relate data fields together. They support composition, allowing structs to contain other structs or reference types as fields, enabling complex data structures.<\/p>\r\n<h4><strong>Prerequisites<\/strong><\/h4>\r\n\r\n\r\n\r\n<p>Hardware : Local <a href=\"https:\/\/go.dev\/\">Machine<\/a><\/p>\r\n\r\n\r\n\r\n<p>Software : <a href=\"https:\/\/prwatech.in\/blog\/software-installation\/installation-of-visual-studio-code-windows\/\" target=\"_blank\" rel=\"noreferrer noopener\" data-type=\"URL\" data-id=\"https:\/\/prwatech.in\/blog\/software-installation\/installation-of-visual-studio-code-windows\/\">VS Code<\/a>, Golang<\/p>\r\n\r\n\r\n\r\n<p>Simple Structure program<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"407\" class=\"wp-image-7486\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28.jpg\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28.jpg 640w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28-300x191.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>check the Output below :<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7487\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1out-2.jpg\" alt=\"\" width=\"539\" height=\"156\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1out-2.jpg 408w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1out-2-300x87.jpg 300w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>Accessing Structure members<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"678\" height=\"650\" class=\"wp-image-7488\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2-29.jpg\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2-29.jpg 678w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2-29-300x288.jpg 300w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7489\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2.1.jpg\" alt=\"\" width=\"575\" height=\"427\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2.1.jpg 507w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2.1-300x222.jpg 300w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n\r\n<p>check the Output :<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7490\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2out-2.jpg\" alt=\"\" width=\"463\" height=\"207\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2out-2.jpg 398w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/2out-2-300x134.jpg 300w\" sizes=\"auto, (max-width: 463px) 100vw, 463px\" \/><\/figure>\r\n<p>They enable developers to model real-world entities and manage data in a structured and type-safe manner.<\/p>\r\n<p>However, you can use pointers to structs to avoid copying large structs and modify the original struct&#8217;s contents directly.<\/p>\r\n<p>Understanding structs is essential for effective Go programming and building scalable and maintainable applications.<\/p>\r\n<\/div>\r\n","protected":false},"excerpt":{"rendered":"<p>Structures in Golang &nbsp; In Go (Golang), structures, also known as structs, are a fundamental composite data type use to define custom data structures with fields. Structs allow developers to encapsulate related data fields into a single entity, providing a way to organize and manage data more effectively. A struct in Go is defined using [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[666,1707],"tags":[668,812,808,815,813,669,814,678],"class_list":["post-7485","post","type-post","status-publish","format-standard","hentry","category-go-lang","category-golang-modules","tag-go","tag-go-lang-tutorial","tag-go-language","tag-go-language-ide","tag-go-language-tutorial","tag-golang","tag-golang-ide","tag-structures-in-golang"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Structures in Golang - Prwatech<\/title>\n<meta name=\"description\" content=\"Master Structures in Golang - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.\" \/>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Structures in Golang - Prwatech\" \/>\n<meta property=\"og:description\" content=\"Master Structures in Golang - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-22T13:37:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-15T07:34:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28.jpg\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/\",\"url\":\"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/\",\"name\":\"Structures in Golang - Prwatech\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28.jpg\",\"datePublished\":\"2021-03-22T13:37:48+00:00\",\"dateModified\":\"2024-04-15T07:34:58+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Master Structures in Golang - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/#primaryimage\",\"url\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28.jpg\",\"contentUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28.jpg\",\"width\":640,\"height\":407},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Structs in Golang\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Structures in Golang - Prwatech","description":"Master Structures in Golang - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Structures in Golang - Prwatech","og_description":"Master Structures in Golang - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.","og_url":"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2021-03-22T13:37:48+00:00","article_modified_time":"2024-04-15T07:34:58+00:00","og_image":[{"url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28.jpg","type":"","width":"","height":""}],"author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/","url":"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/","name":"Structures in Golang - Prwatech","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/#primaryimage"},"image":{"@id":"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/#primaryimage"},"thumbnailUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28.jpg","datePublished":"2021-03-22T13:37:48+00:00","dateModified":"2024-04-15T07:34:58+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Master Structures in Golang - Dive deep with our expert instructors and comprehensive curriculum, Enroll now.","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/#primaryimage","url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28.jpg","contentUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/03\/1-28.jpg","width":640,"height":407},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/go-lang\/structs-in-golang-structures-in-golang\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Structs in Golang"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/7485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=7485"}],"version-history":[{"count":4,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/7485\/revisions"}],"predecessor-version":[{"id":11488,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/7485\/revisions\/11488"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=7485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=7485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=7485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}