- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 911 Articles for Go Programming

Updated on 03-May-2023 10:53:16
In Go programming language, Bufio and io package functions will be used to read the text from the given file. In this article, we will use three Examples to read lines from the existing file. In the first Example, we will use NewReader function from the bufio package, in the second Example we will use ReadFile function from ioutil package and in the third Example we will use file.Read function respectively. Syntax func Split(str, sep string) []string Split() function is used to split a string through a provided separator. This function is present in strings package and it accepts ... Read More 
Updated on 03-May-2023 10:50:43
In this Golang article we will use ReadFile function from the io/ioutil package, NewScanner function from the bufio packageand as well as NewReader function from the former package respectively to read entire text from the xis=sting file. Syntax bufio.NewReader() This function belongs to Go's bufio package. The primary goal of this function is to read the data in larger chunks instead of line by line and store in buffer. The io.reader and buffer size are passed as arguments in this function. os.Open() This function is a part of os package. It is used to open a file to ... Read More 
Updated on 03-May-2023 10:27:40
In golang we can use ioutile.ReadFile() to read the file and for loop timer, we will limit the character numbers to read, Os.Open and bufio.NewReader function to perform the execution as well as file.Read() respectively. In this article we will learn how to use the OS asnd bufio package of Golang to read the specified number of characters from the existing file. Syntax ioutil.ReadFile(file) The ReadFile() function is present in ioutil package and is used to read the given file. The function accepts the file to be read as argument to the function. To read a specified number of ... Read More 
Updated on 03-May-2023 09:56:32
In this golang article, we are going to use os.OpenFile() and ioutil.Readfile() to append the given file without truncating it. In the first Example, we are going to Os.Openfile to access the file and then by using file.WriteString function we will append it. In the second Example, we will use ioutil, ReadFile(), ioutil.WriteFile() and Append() functions to perform the same operation on the file without truncating it respectively. Syntax file.read() The Read() function is used to read the contents of a file. The function accepts the file whose contents are to be read as an argument and returns the ... Read More 
Updated on 03-May-2023 09:51:34
In Golang, read-only mode refers to a mode of operation in which a file, directory, or device can only be viewed or read, but not modified or deleted. This mode is used to prevent accidental changes in the data. In computer systems, the read-only mode can be set at the file or folder level, or it can be set for an entire disk or partition. In this article, we will use three Examples to open a file in read-only mode. In the first Example we will use open function from the os package, in the second Example we will use ... Read More 
Updated on 03-May-2023 09:50:06
In golang we can os.Openfile function of os package and ioutil.WriteFile() function of ioutil package to append a file. Then, we will use WriteString() function to print the result. In this article, we are going to learn how to create a golang programt to open a file in append mode incase the file does not exist. Syntax os.OpenFile(name/path string, flag int, perm FileMode) The OpenFile() function is present in os package. The function accepts three arguments. One is the name of the file that is to be opened followed by the int type instruction used to open a ... Read More 
Updated on 03-May-2023 09:47:21
In Go programming language, os and io packages can be used for performing various operations on external files like copying, editing, and even appending them. In this article, we will learn two Examples to open a file in append mode. In the first Example we will use os.OpenFile function from os package and in the second Example we will use ioutil.WriteFile function from ioutil package. Syntax os.OpenFile("test.txt", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) The OpenFile() function is present in os package and is used to open a file. The function accepts the file to be opened as argument to the function along with ... Read More 
Updated on 03-May-2023 09:46:31
In Golang, the functions os.openfile () and ioutil.Writefile() are used to access/open a file in read-write mode without truncating it. In this article, we will understand the functionality of these two functions using two different methods. In the first method we will use the OpenFile() function present in os package and In the second method, we will use the WriteFile() function to implement the result. Syntax os.OpenFile() The OpenFile() function is present in os package and is used to open a file. The function accepts the file to be opened as argument to the function along with ... Read More 
Updated on 03-May-2023 09:44:13
In Golang, we can use OS functions os.OpenFile(), os.Create() and ioutil.WriteFile to open a write-only file. Here we are going to see three different Examples to understand the functionality of these functions. In the first program we will use the OpenFile() function while in the second and third program, we will use the writeFile() and create() function respectively. Syntax func WriteFile(filename string, data []byte, perm os.FileMode) error The WriteFile() function is present in the ioutil package and is used to write the data in the file. The function accepts the name of file in which data is to be ... Read More 
Updated on 26-Apr-2023 11:25:45
In Golang, repeating a slice of bytes is a common operation that can be useful in many different applications. Fortunately, the bytes package in Golang provides a simple way to repeat a slice of bytes multiple times. In this article, we'll explore how to repeat a slice of bytes in Golang. Repeating a Slice of Bytes in Golang To repeat a slice of bytes in Golang, we can use the bytes.Repeat function provided by the bytes package. The bytes.Repeat function takes two arguments: a slice of bytes to repeat, and the number of times to repeat the slice. Example Here's ... Read More Advertisements