remove Archives - Welcome To Golang By Example https://vikasboss.github.io/tag/remove/ Sun, 23 Feb 2020 17:30:49 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.1 https://i0.wp.com/golangbyexamples.com/wp-content/uploads/2021/05/cropped-go_border-1.png?fit=32%2C32&ssl=1 remove Archives - Welcome To Golang By Example https://vikasboss.github.io/tag/remove/ 32 32 159787465 Delete/Remove a folder in Go (Golang) https://vikasboss.github.io/delete-folder-go/ https://vikasboss.github.io/delete-folder-go/#respond Sun, 23 Feb 2020 17:30:37 +0000 https://vikasboss.github.io/?p=1471 os.Remove() function can be used to delete a folder in Golang. Below is the signature of this function Code: Output:

The post Delete/Remove a folder in Go (Golang) appeared first on Welcome To Golang By Example.

]]>
os.Remove() function can be used to delete a folder in Golang. Below is the signature of this function

func Remove(name string) error

Code:

package main

import (
    "log"
    "os"
)

func main() {
    err := os.Remove("sample")
    if err != nil {
        log.Fatal(err)
    }
}

Output:

Deletes sample folder from the current working directory

The post Delete/Remove a folder in Go (Golang) appeared first on Welcome To Golang By Example.

]]>
https://vikasboss.github.io/delete-folder-go/feed/ 0 1471
Delete a file in Go (Golang) https://vikasboss.github.io/delete-file-go/ https://vikasboss.github.io/delete-file-go/#respond Sun, 23 Feb 2020 17:26:50 +0000 https://vikasboss.github.io/?p=1467 os.Remove() function can be used to delete a file in Golang. Below is the signature of this function Code: Output:

The post Delete a file in Go (Golang) appeared first on Welcome To Golang By Example.

]]>
os.Remove() function can be used to delete a file in Golang. Below is the signature of this function

func Remove(name string) error

Code:

package main

import (
    "log"
    "os"
)

func main() {
    err := os.Remove("sample.txt")
    if err != nil {
        log.Fatal(err)
    }
}

Output:

Deletes sample.txt file from the current working directory

The post Delete a file in Go (Golang) appeared first on Welcome To Golang By Example.

]]>
https://vikasboss.github.io/delete-file-go/feed/ 0 1467