{"id":9896,"date":"2022-09-10T12:31:20","date_gmt":"2022-09-10T12:31:20","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=9896"},"modified":"2024-04-15T10:53:45","modified_gmt":"2024-04-15T10:53:45","slug":"files-and-directories-with-examples","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/","title":{"rendered":"Files and directories with examples"},"content":{"rendered":"<h2><span data-sheets-root=\"1\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Working with Files and Directories&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:513,&quot;3&quot;:{&quot;1&quot;:0},&quot;12&quot;:0}\">Working with Files and Directories<\/span><\/h2>\n<p>&nbsp;<\/p>\n<p>Working with files and directories is a fundamental aspect of software development and system administration. Files represent persistent data stored on storage devices, while directories (or folders) provide a way to organize and structure files hierarchically within a file system.<\/p>\n<p>In software development, interacting with files and directories allows applications to read input data, write output data, store configurations, and manage resources such as logs and temporary files. Common operations include reading from and writing to files, creating, deleting, moving, and renaming files and directories, and querying file metadata such as size, permissions, and timestamps.<\/p>\n<p>File system operations are essential in system administration for managing server configurations, deploying applications, performing backups, and monitoring system health. Administrators use tools and commands to navigate file systems, set permissions, manage file attributes, and troubleshoot disk space issues.<\/p>\n<ul>\n<li>\n<h3><strong><strong><a href=\"https:\/\/go.dev\/\">Create<\/a> an <a href=\"https:\/\/prwatech.in\/blog\/go-lang\/installation-of-go-windows\/\">empty<\/a> file<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main \r\nimport (\r\n    \"log\"\r\n    \"os\"\r\n)\r\n \r\nfunc main() {\r\n    emptyFile, err := os.Create(\"empty.txt\")\r\n    if err != nil {\r\n        log.Fatal(err)\r\n    }\r\n    log.Println(emptyFile)\r\n    emptyFile.Close()\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt; go run empty.go\r\n2022\/08\/20 15:45:16 &amp;{0xc00007e780}\r\n<\/pre>\n<ul>\n<li>\n<h3><strong>Create directory<\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\nimport (\r\n    \"log\"\r\n    \"os\"\r\n) \t\r\nfunc main() {\r\n    _, err := os.Stat(\"text\")\r\n    if os.IsNotExist(err) {\r\n        errDir := os.MkdirAll(\"text\", 0755)\r\n        if errDir != nil {\r\n            log.Fatal(err)\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt; go run create.go<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Rename a file<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\nimport (\r\n    \"log\"\r\n    \"os\"\r\n)\t\r\n \r\nfunc main() {\r\n    oldName := \"test.txt\"\r\n    newName := \"testing.txt\"\r\n    err := os.Rename(oldName, newName)\r\n    if err != nil {\r\n        log.Fatal(err)\r\n    }\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt; go run rename.go<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Copy file at the specified location<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\n\r\nimport (\r\n    \"io\"\r\n    \"log\"\r\n    \"os\"\r\n)\r\n\r\nfunc main() {\r\n\r\n    sourceFile, err := os.Open(\"C:\/GO_Language\/file\/test.txt\")\r\n    if err != nil {\r\n        log.Fatal(err)\r\n    }\r\n    defer sourceFile.Close()\r\n\r\n    \/\/ Create new file\r\n    newFile, err := os.Create(\"C:\/GO_Language\/test.txt \")\r\n    if err != nil {\r\n        log.Fatal(err)\r\n    }\r\n    defer newFile.Close()\r\n\r\n    bytesCopied, err := io.Copy(newFile, sourceFile)\r\n    if err != nil {\r\n        log.Fatal(err)\r\n    }\r\n    log.Printf(\"Copied %d bytes.\", bytesCopied)\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt; go run f1.go\r\n2022\/08\/20 15:39:48 Copied 59 bytes.\r\n<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Move a File<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\n\r\nimport (\r\n    \"log\"\r\n    \"os\"\r\n)\r\n\r\nfunc main() {\r\n    oldLocation := \"C:\/GO_Language\/test.txt\"\r\n    newLocation := \"C:\/GO_Language\/file\/test.txt\"\r\n    err := os.Rename(oldLocation, newLocation)\r\n    if err != nil {\r\n        log.Fatal(err)\r\n    }\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">PS C:\\GO_Language\\file&gt; go run move.go<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Getting Metadata of a file<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\nimport (\r\n    \"fmt\"\r\n    \"log\"\r\n    \"os\"\r\n)\r\n \r\nfunc main() {\r\n    fileStat, err := os.Stat(\"test.txt\")\r\n \r\n    if err != nil {\r\n        log.Fatal(err)\r\n    }\r\n \r\n    fmt.Println(\"File Name:\", fileStat.Name())        \r\n    fmt.Println(\"Size:\", fileStat.Size())             \r\n    fmt.Println(\"Permissions:\", fileStat.Mode())      \r\n    fmt.Println(\"Last Modified:\", fileStat.ModTime()) \r\n    fmt.Println(\"Is Directory: \", fileStat.IsDir())   \r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">PS C:\\GO_Language\\file&gt;  go run matadata.go\r\nFile Name: test.txt\r\nSize: 59\r\nPermissions: -rw-rw-rw-\r\nLast Modified: 2022-08-20 15:39:48.8907731 +0530 IST\r\nIs Directory:  false\r\n<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Deleting a specific file<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\nimport (\r\n    \"log\"\r\n    \"os\"\r\n)\r\n \r\nfunc main() {\r\n    err := os.Remove(\"C:\/GO_Language\/test.txt \")\r\n    if err != nil {\r\n        log.Fatal(err)\r\n    }\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt;  go run delete.go<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Read a text file character by character<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\nimport (\r\n    \"bufio\"\r\n    \"fmt\"\r\n    \"io\/ioutil\"\r\n    \"os\"\r\n    \"strings\"\r\n)\r\n \r\nfunc main() {\r\n    filename := \"test.txt\"\r\n \r\n    filebuffer, err := ioutil.ReadFile(filename)\r\n    if err != nil {\r\n        fmt.Println(err)\r\n        os.Exit(1)\r\n    }\r\n    inputdata := string(filebuffer)\r\n    data := bufio.NewScanner(strings.NewReader(inputdata))\r\n    data.Split(bufio.ScanRunes)\r\n \r\n    for data.Scan() {\r\n        fmt.Print(data.Text())\r\n    }\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt;  go run readchar.go\r\nSandeep \r\nRamesh\r\nShankar \r\nMohan\r\ndhanaji\r\nRajya\r\nSohel\r\n<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Truncate File Content<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\nimport (\r\n    \"log\"\r\n    \"os\"\r\n)\r\n \r\nfunc main() {\r\n    err := os.Truncate(\"test.txt\", 100)\r\n \r\n    if err != nil {\r\n        log.Fatal(err)\r\n    }\r\n}\r\n<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt;  go run truncate.go<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Append Content in a Text File<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\n \r\nimport (\r\n    \"fmt\"\r\n    \"os\"\r\n)\r\n \r\nfunc main() {\r\n    msg := \"Add this content at end\"\r\n    fname := \"test.txt\"\r\n \r\n    f, err := os.OpenFile(fname, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0660)\r\n \r\n    if err != nil {\r\n        fmt.Println(err)\r\n        os.Exit(-1)\r\n    }\r\n    defer f.Close()\r\n \r\n    fmt.Fprintf(f, \"%s\\n\", msg)\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt; go run append.go<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Change file permission, ownership, and timestamps<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\nimport (\r\n\"log\"\r\n\"os\"\r\n\"time\"\r\n)\r\n\r\nfunc main() {\r\n_, err := os.Stat(\"test.txt\")\r\nif err != nil {\r\nif os.IsNotExist(err) {\r\nlog.Fatal(\"File does not exist.\")\r\n}\r\n}\r\nlog.Println(\"File exist.\")\r\n\r\n\/\/ Change permissions Linux.\r\nerr = os.Chmod(\"test.txt\", 0777)\r\nif err != nil {\r\nlog.Println(err)\r\n}\r\n\r\n\/\/ Change file ownership.\r\nerr = os.Chown(\"test.txt\", os.Getuid(), os.Getgid())\r\nif err != nil {\r\nlog.Println(err)\r\n}\r\n\r\n\/\/ Change file timestamps.\r\naddOneDayFromNow := time.Now().Add(24 * time.Hour)\r\nlastAccessTime := addOneDayFromNow\r\nlastModifyTime := addOneDayFromNow\r\nerr = os.Chtimes(\"test.txt\", lastAccessTime, lastModifyTime)\r\nif err != nil {\r\nlog.Println(err)\r\n}\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt; go run change.go\r\n2022\/08\/20 16:55:42 File exist.\r\n2022\/08\/20 16:55:42 chown test.txt: not supported by windows\r\n<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Compress a list of files into a ZIP file<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\nimport (\r\n    \"archive\/zip\"\r\n    \"fmt\"\r\n    \"io\"\r\n    \"log\"\r\n    \"os\"\r\n)\r\n \r\nfunc appendFiles(fname string, zipw *zip.Writer) error {\r\n    file, err := os.Open(fname)\r\n    if err != nil {\r\n        return fmt.Errorf(\"Failed to open %s: %s\", fname, err)\r\n    }\r\n    defer file.Close()\r\n \r\n    wr, err := zipw.Create(fname)\r\n    if err != nil {\r\n        msg := \"Failed to create entry for %s in zip file: %s\"\r\n        return fmt.Errorf(msg, fname, err)\r\n    }\r\n \r\n    if _, err := io.Copy(wr, file); err != nil {\r\n        return fmt.Errorf(\"Failed to write %s to zip: %s\", fname, err)\r\n    }\r\n \r\n    return nil\r\n}\r\n \r\nfunc main() {\r\n    flags := os.O_WRONLY | os.O_CREATE | os.O_TRUNC\r\n    file, err := os.OpenFile(\"test.zip\", flags, 0644)\r\n    if err != nil {\r\n        log.Fatalf(\"Failed to open zip for writing: %s\", err)\r\n    }\r\n    defer file.Close()\r\n \r\n    var files = []string{\"test1.txt\", \"test2.txt\", \"test3.txt\"}\r\n \r\n    zipw := zip.NewWriter(file)\r\n    defer zipw.Close()\r\n \r\n    for _, filename := range files {\r\n        if err := appendFiles(filename, zipw); err != nil {\r\n            log.Fatalf(\"Failed to add file %s to zip: %s\", fname, err)\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt; go run compress.go<\/pre>\n<p>&nbsp;<\/li>\n<li>\n<h3><strong><strong>Extract or Unzip<\/strong><\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"golang\">package main\r\nimport (\r\n    \"archive\/zip\"\r\n    \"io\"\r\n    \"log\"\r\n    \"os\"\r\n    \"path\/filepath\"\r\n)\r\n \r\nfunc main() {\r\n    zipReader, _ := zip.OpenReader(\"test.zip\")\r\n    for _, file := range zipReader.Reader.File {\r\n \r\n        zippedFile, err := file.Open()\r\n        if err != nil {\r\n            log.Fatal(err)\r\n        }\r\n        defer zippedFile.Close()\r\n \r\n        tDir := \".\/\"\r\n        extractedFilePath := filepath.Join(\r\n            tDir,\r\n            file.Name,\r\n        )\r\n \r\n        if file.FileInfo().IsDir() {\r\n            log.Println(\"Directory Created:\", extractedFilePath)\r\n            os.MkdirAll(extractedFilePath, file.Mode())\r\n        } else {\r\n            log.Println(\"File extracted:\", file.Name)\r\n \r\n            opFile, err := os.OpenFile(\r\n                extractedFilePath,\r\n                os.O_WRONLY|os.O_CREATE|os.O_TRUNC,\r\n                file.Mode(),\r\n            )\r\n            if err != nil {\r\n                log.Fatal(err)\r\n            }\r\n            defer opFile.Close()\r\n \r\n            _, err = io.Copy(opFile, zippedFile)\r\n            if err != nil {\r\n                log.Fatal(err)\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Output :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">PS C:\\GO_Language\\file&gt; go run extract.go \r\n2022\/08\/20 17:11:43 File extracted: test1.txt\r\n2022\/08\/20 17:11:43 File extracted: test2.txt\r\n2022\/08\/20 17:11:43 File extracted: test3.txt\r\n<\/pre>\n<p>&nbsp;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Working with Files and Directories &nbsp; Working with files and directories is a fundamental aspect of software development and system administration. Files represent persistent data stored on storage devices, while directories (or folders) provide a way to organize and structure files hierarchically within a file system. In software development, interacting with files and directories allows [&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":[1613,1617,1612,1616,1611,1614,1615,1618],"class_list":["post-9896","post","type-post","status-publish","format-standard","hentry","category-go-lang","category-golang-modules","tag-copy-file","tag-delete-file","tag-directories","tag-empty-file","tag-file-handling","tag-move-file","tag-rename-file","tag-truncate-file"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Working with Files and Directories - Prwatech<\/title>\n<meta name=\"description\" content=\"Master Working with Files and Directories in Go - Dive deep with our expert instructors and comprehensive curriculum.\" \/>\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=\"Working with Files and Directories - Prwatech\" \/>\n<meta property=\"og:description\" content=\"Master Working with Files and Directories in Go - Dive deep with our expert instructors and comprehensive curriculum.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/\" \/>\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=\"2022-09-10T12:31:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-15T10:53:45+00:00\" \/>\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=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/\",\"url\":\"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/\",\"name\":\"Working with Files and Directories - Prwatech\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"datePublished\":\"2022-09-10T12:31:20+00:00\",\"dateModified\":\"2024-04-15T10:53:45+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Master Working with Files and Directories in Go - Dive deep with our expert instructors and comprehensive curriculum.\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Files and directories with examples\"}]},{\"@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":"Working with Files and Directories - Prwatech","description":"Master Working with Files and Directories in Go - Dive deep with our expert instructors and comprehensive curriculum.","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":"Working with Files and Directories - Prwatech","og_description":"Master Working with Files and Directories in Go - Dive deep with our expert instructors and comprehensive curriculum.","og_url":"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2022-09-10T12:31:20+00:00","article_modified_time":"2024-04-15T10:53:45+00:00","author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/","url":"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/","name":"Working with Files and Directories - Prwatech","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"datePublished":"2022-09-10T12:31:20+00:00","dateModified":"2024-04-15T10:53:45+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Master Working with Files and Directories in Go - Dive deep with our expert instructors and comprehensive curriculum.","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/go-lang\/files-and-directories-with-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Files and directories with examples"}]},{"@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\/9896","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=9896"}],"version-history":[{"count":4,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/9896\/revisions"}],"predecessor-version":[{"id":11547,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/9896\/revisions\/11547"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=9896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=9896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=9896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}