{"id":223,"date":"2026-04-16T09:00:00","date_gmt":"2026-04-16T03:30:00","guid":{"rendered":"https:\/\/smitabharat.com\/blog\/?p=223"},"modified":"2026-10-10T21:20:48","modified_gmt":"2026-10-10T15:50:48","slug":"go-file-handling-examples","status":"publish","type":"post","link":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/","title":{"rendered":"Go File Handling Explained with Examples"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Go file handling lets your program save data to disk and read it back, from simple notes to large log files. In this post, you will write, read and append to files, read line by line and work with folders. Each idea comes with a short example that you can run yourself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Every file function here returns an error, so a quick look at <a href=\"https:\/\/smitabharat.com\/blog\/go-error-handling-guide\/\">error handling in Go for beginners<\/a> will help. We will also use <code>defer<\/code> to close files, which you met in <a href=\"https:\/\/smitabharat.com\/blog\/go-functions-beginners-guide\/\">writing and calling functions in Go<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Is Go File Handling?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To begin with, file handling means creating, reading, changing and removing files from your code. Go keeps the main tools in the <code>os<\/code> package, with helpers in <code>bufio<\/code> and <code>path\/filepath<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, think of a notebook on your desk. You open it, write or read a page, and close it when you finish. Go file handling follows exactly the same steps.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Writing a File with os.WriteFile<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>err := os.WriteFile(\"notes.txt\", &#91;]byte(\"Learn Go\\nWrite tests\\n\"), 0644)\nif err != nil {\n\tfmt.Println(err)\n\treturn\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In short, this one call creates the file, writes the bytes and closes it. However, if the file already exists, it replaces the old content. The number <code>0644<\/code> sets the file permissions, which we explain below.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reading a File with os.ReadFile<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>data, err := os.ReadFile(\"notes.txt\")\nif err != nil {\n\tfmt.Println(err)\n\treturn\n}\nfmt.Print(string(data))\n\/\/ Learn Go\n\/\/ Write tests<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In fact, ReadFile loads the whole file into memory at once. So it is perfect for small files like configs, but not for huge logs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Go File Handling Step by Step: Open, Use, Close<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Next, for more control, you open a file, work with it and then close it. The diagram below shows this flow, which every bigger file task follows.<\/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-file-handling-examples-diagram-1024x640.png\" alt=\"Go File Handling diagram showing the open, check error, defer Close, read or write flow\" class=\"wp-image-225\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-examples-diagram-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-examples-diagram-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-examples-diagram-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-examples-diagram-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-examples-diagram-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Open the file, check the error, defer Close, then read or write until you are done.<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Appending with os.OpenFile<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>f, err := os.OpenFile(\"notes.txt\", os.O_APPEND|os.O_WRONLY, 0644)\nif err != nil {\n\tfmt.Println(err)\n\treturn\n}\ndefer f.Close()\n\nf.WriteString(\"Ship it\\n\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">First, the flags tell Go how to open the file. Here <code>O_APPEND<\/code> adds to the end, while <code>O_WRONLY<\/code> opens it for writing only. Also, <code>defer f.Close()<\/code> makes sure the file closes when the function ends.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reading Line by Line with bufio.Scanner<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>file, err := os.Open(\"notes.txt\")\nif err != nil {\n\tfmt.Println(err)\n\treturn\n}\ndefer file.Close()\n\nscanner := bufio.NewScanner(file)\nline := 1\nfor scanner.Scan() {\n\tfmt.Println(line, scanner.Text())\n\tline++\n}\nif err := scanner.Err(); err != nil {\n\tfmt.Println(err)\n}\n\/\/ 1 Learn Go\n\/\/ 2 Write tests\n\/\/ 3 Ship it<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For Go file handling at scale, a Scanner reads one line at a time, so memory stays low even for giant files. Remember to check <code>scanner.Err()<\/code> after the loop, because Scan simply stops on errors.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Go File Handling: Checking if a File Exists<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>_, err = os.ReadFile(\"missing.txt\")\nfmt.Println(err)                            \/\/ open missing.txt: no such file or directory\nfmt.Println(errors.Is(err, fs.ErrNotExist)) \/\/ true\n\ninfo, _ := os.Stat(\"notes.txt\")\nfmt.Println(info.Name(), info.Size()) \/\/ notes.txt 29<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>errors.Is<\/code> with <code>fs.ErrNotExist<\/code> to check for a missing file. Meanwhile, <code>os.Stat<\/code> gives details such as the name and size in bytes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Folders and Paths in Go File Handling<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>os.MkdirAll(filepath.Join(\"data\", \"logs\"), 0755)\nfmt.Println(filepath.Join(\"data\", \"logs\", \"app.log\")) \/\/ data\/logs\/app.log\n\nos.Remove(\"notes.txt\")\nos.RemoveAll(\"data\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>MkdirAll<\/code> creates a folder and any missing parents. Also, <code>filepath.Join<\/code> builds paths with the right slash for each system, so your code works on Windows, macOS and Linux.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">File Permissions Explained<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Value<\/th><th>Owner<\/th><th>Group and others<\/th><th>Typical use<\/th><\/tr><\/thead><tbody><tr><td>0644<\/td><td>read and write<\/td><td>read only<\/td><td>Normal files<\/td><\/tr><tr><td>0600<\/td><td>read and write<\/td><td>no access<\/td><td>Secret files<\/td><\/tr><tr><td>0755<\/td><td>full access<\/td><td>read and open<\/td><td>Folders<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In addition, the leading 0 means the number is octal. On Windows these values matter less, but always pass a sensible one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes in Go File Handling<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem you see<\/th><th>Why it happens<\/th><th>How to fix it<\/th><\/tr><\/thead><tbody><tr><td>open missing.txt: no such file or directory<\/td><td>The path is wrong or relative to another folder.<\/td><td>Check the path and your working folder.<\/td><\/tr><tr><td>&#8220;too many open files&#8221;<\/td><td>The code never closed files in a loop.<\/td><td>Close each file, ideally with defer.<\/td><\/tr><tr><td>Old content disappears<\/td><td>WriteFile replaced the file.<\/td><td>Use OpenFile with O_APPEND.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Also, relative paths start from where you run the program, not where the code lives. File questions also appear in my <a href=\"https:\/\/smitabharat.com\/blog\/go-lang-interview-questions-and-answers\/\">Go interview questions and answers<\/a>, so practise them there.<\/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 accurate and up to date.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pkg.go.dev\/os\">os package documentation<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pkg.go.dev\/bufio\">bufio package documentation<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pkg.go.dev\/path\/filepath\">path\/filepath 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 file handling lives mainly in the os package.<\/li>\n\n\n\n<li>WriteFile and ReadFile handle small files in one call.<\/li>\n\n\n\n<li>For more control, open the file, defer Close, then read or write.<\/li>\n\n\n\n<li>bufio.Scanner reads big files line by line.<\/li>\n\n\n\n<li>Use filepath.Join for paths and errors.Is to spot missing files.<\/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 store data on disk. Next, we will share data over the network by building your first web server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Coming soon: Go HTTP Server: Build Your First Web Server<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go file handling lets your program save data to disk and read it back, from simple notes to large log files. In this post,&hellip;<\/p>\n","protected":false},"author":1,"featured_media":224,"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":[43,11,23,21],"swapz_series":[],"class_list":["post-223","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go-lang","tag-go-file-handling","tag-go-lang","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 File Handling Explained with Simple Examples<\/title>\n<meta name=\"description\" content=\"Learn Go file handling with simple examples: write, read and append data, read line by line, build paths and set permissions.\" \/>\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-file-handling-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go File Handling Explained with Simple Examples\" \/>\n<meta property=\"og:description\" content=\"Learn Go file handling with simple examples: write, read and append data, read line by line, build paths and set permissions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"Smita Bharat - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-16T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-10T15:50:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-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-file-handling-examples\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/\"},\"author\":{\"name\":\"Smita\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"headline\":\"Go File Handling Explained with Examples\",\"datePublished\":\"2026-04-16T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:50:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/\"},\"wordCount\":684,\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-file-handling-examples-featured.png\",\"keywords\":[\"Go File Handling\",\"Go Lang\",\"Go Tutorial\",\"Golang Basics\"],\"articleSection\":[\"Go Lang\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/\",\"name\":\"Go File Handling Explained with Simple Examples\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-file-handling-examples-featured.png\",\"datePublished\":\"2026-04-16T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:50:48+00:00\",\"description\":\"Learn Go file handling with simple examples: write, read and append data, read line by line, build paths and set permissions.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/#primaryimage\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-file-handling-examples-featured.png\",\"contentUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-file-handling-examples-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Go File Handling featured image: cards showing WriteFile, ReadFile and bufio.Scanner\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-file-handling-examples\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go File Handling 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 File Handling Explained with Simple Examples","description":"Learn Go file handling with simple examples: write, read and append data, read line by line, build paths and set permissions.","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-file-handling-examples\/","og_locale":"en_US","og_type":"article","og_title":"Go File Handling Explained with Simple Examples","og_description":"Learn Go file handling with simple examples: write, read and append data, read line by line, build paths and set permissions.","og_url":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/","og_site_name":"Smita Bharat - Blog","article_published_time":"2026-04-16T03:30:00+00:00","article_modified_time":"2026-10-10T15:50:48+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-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-file-handling-examples\/#article","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/"},"author":{"name":"Smita","@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"headline":"Go File Handling Explained with Examples","datePublished":"2026-04-16T03:30:00+00:00","dateModified":"2026-10-10T15:50:48+00:00","mainEntityOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/"},"wordCount":684,"publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-examples-featured.png","keywords":["Go File Handling","Go Lang","Go Tutorial","Golang Basics"],"articleSection":["Go Lang"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/","url":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/","name":"Go File Handling Explained with Simple Examples","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/#primaryimage"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-examples-featured.png","datePublished":"2026-04-16T03:30:00+00:00","dateModified":"2026-10-10T15:50:48+00:00","description":"Learn Go file handling with simple examples: write, read and append data, read line by line, build paths and set permissions.","breadcrumb":{"@id":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/#primaryimage","url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-examples-featured.png","contentUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-file-handling-examples-featured.png","width":2400,"height":1260,"caption":"Go File Handling featured image: cards showing WriteFile, ReadFile and bufio.Scanner"},{"@type":"BreadcrumbList","@id":"https:\/\/smitabharat.com\/blog\/go-file-handling-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smitabharat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go File Handling 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\/223","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=223"}],"version-history":[{"count":2,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/223\/revisions"}],"predecessor-version":[{"id":227,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/223\/revisions\/227"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media\/224"}],"wp:attachment":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media?parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/categories?post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/tags?post=223"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}