Akhil Sharma has Published 507 Articles

Golang program to append a string in an existing file

Akhil Sharma

Akhil Sharma

Updated on 22-Feb-2023 14:52:52

1K+ Views

In Golang, we can use io and os packages to append a string in an existing file. file contains data that can be manipulated in many ways like editing and writing the data. In this article the first method will demonstrate the application of os.Open file of OS package. ... Read More

Golang program to get the file extension

Akhil Sharma

Akhil Sharma

Updated on 22-Feb-2023 14:51:41

7K+ Views

In golang, we can use the path package and string package to get the extension of a particular file. Here, in his article, we will obtain the file extension using two methods. In the first method, we will use path package function path.Ext. In the second method, we will use ... Read More

Golang program to get the relative path from two absolute paths

Akhil Sharma

Akhil Sharma

Updated on 22-Feb-2023 14:50:38

5K+ Views

To get the relative path from two absolute paths in golang, we use filepath and string packages. Relative paths tell the location of file with respect to present working directory whereas absolute paths tell the location of file starting from root directory. In the first method we will use filepath ... Read More

Golang program to get the name of the file from the absolute path

Akhil Sharma

Akhil Sharma

Updated on 22-Feb-2023 14:49:18

12K+ Views

We are going to use the filepath and string functions of golang to get the file name from the absolute path. An absolute directory begins with the root directory and includes all intermediate directories. In the first method, we will use filepath package functions and in the second example, we ... Read More

Golang program to create directories

Akhil Sharma

Akhil Sharma

Updated on 22-Feb-2023 14:48:16

3K+ Views

Golang has internal packages like os and io packages for creating a new directory. Here, we will create a directory using two examples. In the first example we will use os.Mkdir function and in the second example we will use ioutil.WriteFile function to execute the program. Method 1: Using os.Mkdir ... Read More

Golang program to copy one file into another file

Akhil Sharma

Akhil Sharma

Updated on 22-Feb-2023 14:40:05

4K+ Views

In Golang, we can use Os Packages and IO packages to copy data from one file to another file. n the first method, we'll use OS packages like os.open, os.create and os.copy function. Whereas in the second method, we will use ioutill.Readfile and ioutil.Writefile to copy the files. Method1: ... Read More

Golang Program to check a specified file is exist or not

Akhil Sharma

Akhil Sharma

Updated on 22-Feb-2023 14:34:59

1K+ Views

In golang, we have internal function like stat(), Open(0 and Readfile() that is used for checking whether a specific file exist or not. In the first example we are using the stat() method present in the os package while in the second and third example we are using Open() ... Read More

Golang Program to check a file has writable permission or not

Akhil Sharma

Akhil Sharma

Updated on 22-Feb-2023 14:33:43

3K+ Views

In Golang, we can use openfile() and Stat() function to check whehter a file has writable permission or not. Here we have written two examples. in the first one we are using OpenFile() method present in the os package while in the second one we are using the Stat() method ... Read More

Golang Program to check a directory is exist or not

Akhil Sharma

Akhil Sharma

Updated on 22-Feb-2023 14:27:40

8K+ Views

In golang we have different inbuild function like Stat(), Open() and mkdir() to check whether a directory exist or not . Here we are using three functions. in the first one we are using the Stat() function present in the os package while in the second and third ... Read More

Golang Program to remove a specified directory

Akhil Sharma

Akhil Sharma

Updated on 22-Feb-2023 14:25:39

5K+ Views

Golang provides several methods to remove a specified directory, including using the os and filepath packages. Removing a directory is a critical operation, and caution should be exercised when performing this task. This article will discuss the different methods to remove a directory in Golang, along with the syntax and ... Read More

Advertisements