- 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 1082 Articles for Go Programming
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
1K+ Views
In this golang article we will write a go language program to search for a file in a directory using os.Open() function as well as using the ioutil.ReadDir() function. Searching for a specific file in golang can be very difficult task, if you have a lot of files to search, but golang makes this a easy task with its built In functions, we will see the use case of such functions in this article. Algorithm First, we need to import the "fmt" and "os" packages. Then, start the main() function. Inside the main() define the name of the directory ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
133 Views
In this golang article, we will delete a directory in Golang using thhe os.Remove() function as well as using os.RemoveAll() function. There are many inbuilt functions present in go to remove a directory, and we will discuss two of such methods in this program. In computer languages a directory is a container or a file system object that contains information about files and other directories. Syntax funcRemove(file_name string) error The remove function is present in os package and is used to remove a particular file or directory. The function accepts one argument which is the name of the file ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
2K+ Views
In this golang article we will write a program to create directories recursively using os.MkdirAll() function as well as using recursion. One of the main use cases of Go is to create scalable and concurrent applications. Method 1 In this Example we will write a go language program to create directories recursively by using MkdirAll() function present in os package. The simplest way to create directories recursively in Golang is by using this function. This function takes a file path as an argument and creates all the missing directories in the path. Syntax funcMkdirAll(path string, perm FileMode) error The ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
879 Views
In this golang article, we can send email using SMTP’s SendMail method, as well as using SMTP with go mail method, SMTP stands for simple mail transfer protocol. This protocol is used to send messages between the servers. The net/smtp package provides a medium to send messages hence it must be imported in the program. Syntax smtp.PlainAuth() This function belongs to the smtp and is primarily used to authenticate with the SMTP server using plain authentication. smtp.SendMail() This function is present in the SMTP package. It is used to send the message from the SMTP server. smtpClient.Auth() ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
223 Views
In this Go language article, we will write programs to implement recursive anonymous function by generating fibonacci numbers, by using cache, as well as factorial of a number. An anonymous function is the function which does not have its name and it calls itself within its own body and when repeated calls are made, it called as recursive functions. Method 1 In this Example, we will generate Fibonacci numbers recursively by using an anonymous function. Here, fibo is assigned to the anonymous function with func and an input parameter. Algorithm Step 1 − Create a package main and declare ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
118 Views
In this golang article, we will learn the overview testing package using two test functions as well as using iteration. Testing is of two types: manual testing and automated testing, manual testing is done manually with defined set of test cases whereas in automated testing a program is created with code to test the software. Here we will use two test function as well as iteration method to show the importance of testing package. Algorithm Step 1 −Import the required packages in the program Step 2 − Create a test function in which the function will be called which ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
70 Views
In this golang article, we will write Go language programs to depict short variable declaration operator using var keyword and variable declaration. In shorthand variable, initialization is done at the time of declaration where it’s not necessary in var keyword. Here, we will use a string method, as well as a count variable method to depict short variable declaration. Algorithm Step 1 − Import the required packages in the program Step 2 − Create a main function Step 3 − In the main use short variable declaration to create strings Step 4 − Print the strings created via shorthand ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
454 Views
In Golang, os and io packages are used for performing various file-r operations like editing, copying, creating, and deleting. In this article, we are going to see three different Examples to create an empty file. In the first Example we will use os.Create from the os package, in the second Example we will use WriteFile function from ioutil package is used and in the third Example we will use NewWriter function from bufio package is used. Syntax os.Create() This function comes from the os package. It helps in the creation of a new file. The filename is given as ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
105 Views
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
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
302 Views
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