{"id":285,"date":"2026-04-24T09:00:00","date_gmt":"2026-04-24T03:30:00","guid":{"rendered":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/"},"modified":"2026-10-10T21:20:55","modified_gmt":"2026-10-10T15:50:55","slug":"go-struct-embedding-examples","status":"publish","type":"post","link":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/","title":{"rendered":"Go Struct Embedding Explained with Examples"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Go struct embedding lets you place one struct inside another so the outer struct reuses its fields and methods. In this post, you will see promoted fields, promoted methods, overriding and how embedding helps with interfaces. Each idea comes with a short example that you can run yourself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First, make sure you are comfortable with <a href=\"https:\/\/smitabharat.com\/blog\/go-structs-beginners-guide\/\">structs and methods in Go<\/a>. We will also satisfy interfaces through embedding, so <a href=\"https:\/\/smitabharat.com\/blog\/go-interfaces-examples\/\">interfaces in Go with examples<\/a> is a useful refresher.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Is Go Struct Embedding?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Go has no classes and no inheritance. Instead, it prefers composition, which means building bigger types from smaller ones. Embedding is the shortcut for that. You list a type inside a struct without giving it a field name.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>type Animal struct {\n\tName string\n\tLegs int\n}\n\nfunc (a Animal) Describe() string {\n\treturn fmt.Sprintf(\"%s has %d legs\", a.Name, a.Legs)\n}\n\ntype Dog struct {\n\tAnimal \/\/ embedded, no field name\n\tBreed  string\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Think of a phone with a built-in camera. The phone does not become a camera, but you can still press the camera button directly on the phone.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Promoted Fields and Methods<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>d := Dog{Animal: Animal{Name: \"Bruno\", Legs: 4}, Breed: \"Labrador\"}\nfmt.Println(d.Name, d.Legs, d.Breed) \/\/ Bruno 4 Labrador\nfmt.Println(d.Describe())            \/\/ Bruno has 4 legs\nfmt.Printf(\"%+v\\n\", d)               \/\/ {Animal:{Name:Bruno Legs:4} Breed:Labrador}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can write <code>d.Name<\/code> instead of <code>d.Animal.Name<\/code>. In other words, Go &#8220;promotes&#8221; the inner fields and methods to the outer struct. However, the inner struct still exists, and its field name is simply its type name, <code>Animal<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Overriding Methods in Go Struct Embedding<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>func (a Animal) Sound() string { return \"...\" }\nfunc (d Dog) Sound() string    { return \"Woof\" }\n\nfmt.Println(d.Sound())        \/\/ Woof\nfmt.Println(d.Animal.Sound()) \/\/ ...<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When both types have a method with the same name, the outer one wins. The diagram below shows how Go looks up <code>d.Name<\/code> and <code>d.Sound()<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-diagram-1024x640.png\" alt=\"Go Struct Embedding diagram showing how Go looks up d.Sound and d.Name in a Dog that embeds Animal\" class=\"wp-image-261\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-diagram-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-diagram-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-diagram-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-diagram-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-diagram-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Go checks the outer struct first and then the embedded struct, so Dog&#8217;s own Sound wins while Name comes from Animal.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The inner method is still reachable through <code>d.Animal.Sound()<\/code>. So you can call it when the outer method wants to add to it rather than replace it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Go Struct Embedding and Interfaces<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>type Speaker interface{ Sound() string }\n\nvar sp Speaker = d\nfmt.Println(sp.Sound()) \/\/ Woof<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Promoted methods count toward interfaces. As a result, a struct can satisfy an interface using methods it gets from an embedded type.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reusing Helpers Like a Logger<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>type Logger struct{ Prefix string }\n\nfunc (l Logger) Log(msg string) { fmt.Println(l.Prefix + msg) }\n\ntype Service struct {\n\tLogger\n\tName string\n}\n\ns := Service{Logger: Logger{Prefix: \"[orders] \"}, Name: \"orders\"}\ns.Log(\"service started\") \/\/ [orders] service started<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is the most common real use of Go struct embedding. Small helper types add shared behaviour to many services without copy-paste. For example, many programs embed <code>sync.Mutex<\/code> so a struct gains <code>Lock<\/code> and <code>Unlock<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Embedding sync.Mutex<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>type Counter struct {\n\tsync.Mutex\n\tn int\n}\n\nfunc (c *Counter) Inc() {\n\tc.Lock()\n\tdefer c.Unlock()\n\tc.n++\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here <code>c.Lock()<\/code> is really <code>c.Mutex.Lock()<\/code>, promoted from the embedded mutex. So the counter is safe to use from many goroutines, as you saw in <a href=\"https:\/\/smitabharat.com\/blog\/go-sync-package-waitgroup-mutex\/\">the Go sync package<\/a>. However, keep in mind that embedding also exports <code>Lock<\/code> to every caller. If you want to hide it, use a named field like <code>mu sync.Mutex<\/code> instead.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Embedding Is Not Inheritance<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>func show(a Animal) {}\n\nshow(d)\n\/\/ cannot use d (variable of struct type Dog) as Animal value in argument to show<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A <code>Dog<\/code> is not an <code>Animal<\/code> in Go. Therefore, you cannot pass it where an <code>Animal<\/code> is expected. Pass <code>d.Animal<\/code> instead, or better, accept an interface. This keeps Go struct embedding simple and predictable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Go Struct Embedding<\/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>ambiguous selector c.Name<\/td><td>Two embedded structs both have Name.<\/td><td>Write <code>c.A.Name<\/code> or <code>c.B.Name<\/code>.<\/td><\/tr><tr><td>cannot use d (variable of struct type Dog) as Animal value<\/td><td>Embedding is not inheritance.<\/td><td>Pass <code>d.Animal<\/code> or use an interface.<\/td><\/tr><tr><td>Inner method ignores the outer override<\/td><td>The inner method calls its own version.<\/td><td>Pass behaviour in with an interface.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The last row surprises people who know Java. Inside <code>Animal<\/code>, methods only see <code>Animal<\/code>, never the outer <code>Dog<\/code>. Embedding questions are common in interviews too, so practise with my <a href=\"https:\/\/smitabharat.com\/blog\/go-lang-interview-questions-and-answers\/\">Go interview questions and answers<\/a>.<\/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 stay accurate and up to date.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/go.dev\/doc\/effective_go#embedding\">Effective Go: Embedding<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/go.dev\/ref\/spec#Struct_types\">Go spec: Struct types<\/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 struct embedding places a type inside a struct without a field name.<\/li>\n\n\n\n<li>Fields and methods of the inner type are promoted to the outer one.<\/li>\n\n\n\n<li>An outer method with the same name overrides the inner one.<\/li>\n\n\n\n<li>Promoted methods help the outer struct satisfy interfaces.<\/li>\n\n\n\n<li>Embedding is composition, not inheritance.<\/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\">You can now build bigger types from small ones. Next, we will return to concurrency and wait on many channels at once with the select statement.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next lesson: <a href=\"https:\/\/smitabharat.com\/blog\/go-select-statement\/\">Go Select Statement Explained with Examples<\/a><\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Go struct embedding lets you place one struct inside another so the outer struct reuses its fields and methods. In this post, you will&hellip;<\/p>\n","protected":false},"author":1,"featured_media":260,"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,51,23,21],"swapz_series":[],"class_list":["post-285","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go-lang","tag-go-lang","tag-go-struct-embedding","tag-go-tutorial","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 Struct Embedding Explained with Examples<\/title>\n<meta name=\"description\" content=\"Learn Go struct embedding with simple examples: promoted fields and methods, overriding, interfaces and why it is not inheritance.\" \/>\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-struct-embedding-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go Struct Embedding Explained with Examples\" \/>\n<meta property=\"og:description\" content=\"Learn Go struct embedding with simple examples: promoted fields and methods, overriding, interfaces and why it is not inheritance.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"Smita Bharat - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-24T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-10T15:50:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/\"},\"author\":{\"name\":\"Smita\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"headline\":\"Go Struct Embedding Explained with Examples\",\"datePublished\":\"2026-04-24T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:50:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/\"},\"wordCount\":629,\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-struct-embedding-examples-featured.png\",\"keywords\":[\"Go Lang\",\"Go Struct Embedding\",\"Go Tutorial\",\"Golang Basics\"],\"articleSection\":[\"Go Lang\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/\",\"name\":\"Go Struct Embedding Explained with Examples\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-struct-embedding-examples-featured.png\",\"datePublished\":\"2026-04-24T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:50:55+00:00\",\"description\":\"Learn Go struct embedding with simple examples: promoted fields and methods, overriding, interfaces and why it is not inheritance.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/#primaryimage\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-struct-embedding-examples-featured.png\",\"contentUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-struct-embedding-examples-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Go Struct Embedding featured image: cards for embedding, promoted fields and overriding\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-struct-embedding-examples\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go Struct Embedding Explained with Examples\"}]},{\"@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 Struct Embedding Explained with Examples","description":"Learn Go struct embedding with simple examples: promoted fields and methods, overriding, interfaces and why it is not inheritance.","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-struct-embedding-examples\/","og_locale":"en_US","og_type":"article","og_title":"Go Struct Embedding Explained with Examples","og_description":"Learn Go struct embedding with simple examples: promoted fields and methods, overriding, interfaces and why it is not inheritance.","og_url":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/","og_site_name":"Smita Bharat - Blog","article_published_time":"2026-04-24T03:30:00+00:00","article_modified_time":"2026-10-10T15:50:55+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-featured.png","type":"image\/png"}],"author":"Smita","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Smita","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/#article","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/"},"author":{"name":"Smita","@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"headline":"Go Struct Embedding Explained with Examples","datePublished":"2026-04-24T03:30:00+00:00","dateModified":"2026-10-10T15:50:55+00:00","mainEntityOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/"},"wordCount":629,"publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-featured.png","keywords":["Go Lang","Go Struct Embedding","Go Tutorial","Golang Basics"],"articleSection":["Go Lang"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/","url":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/","name":"Go Struct Embedding Explained with Examples","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/#primaryimage"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-featured.png","datePublished":"2026-04-24T03:30:00+00:00","dateModified":"2026-10-10T15:50:55+00:00","description":"Learn Go struct embedding with simple examples: promoted fields and methods, overriding, interfaces and why it is not inheritance.","breadcrumb":{"@id":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/#primaryimage","url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-featured.png","contentUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-struct-embedding-examples-featured.png","width":2400,"height":1260,"caption":"Go Struct Embedding featured image: cards for embedding, promoted fields and overriding"},{"@type":"BreadcrumbList","@id":"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smitabharat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go Struct Embedding Explained with Examples"}]},{"@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\/285","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=285"}],"version-history":[{"count":1,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/285\/revisions"}],"predecessor-version":[{"id":300,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/285\/revisions\/300"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media\/260"}],"wp:attachment":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media?parent=285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/categories?post=285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/tags?post=285"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}