Golang Log: How to Log in Go

In the computing paradigm, a log file is a file that records either events that occur in the operating system or other software runs or messages between the different users of communication software. Logging is an act of keeping a log. In the simplest case, messages are written to a single log file. Golang Log … Read more

How to Write File in Golang

In programming, you will come across file handling and the basics of file operations at some point. Of course, reading and writing files are the most basic operations. In this case, to make things easy, all you need to know is how this data is structured so that you can parse and modify it to … Read more

Golang File Open: How to Open File in Golang

Golang has a built-in package called os, which has a function called OpenFile() that can be used to open a file. We can open a file using the os.OpenFile() function. First, we must import the os package and then use the method. The reader and writer interfaces in Golang are similar abstractions. We read and write bytes … Read more

Golang os.Create(): How to Create File in Go

File create, read, and write the basic operations in Go. We can create a file using the os.Create() function. First, we must import the os package and then use its method. How to create a file in Golang To create a file in Golang, use the os.Create() function. Golang has a built-in os.Create() function that takes the … Read more

Golang Delete File: How to Remove File in Go

Deleting files in Go is that simple. File delete, file create, file read, and file writes. Almost all the file operations are done through the os package. So if you want to manage files in Golang, you need to use Golang’s built-in os package. Golang delete file To delete a file in Golang, use the os.Remove() function. … Read more

How to Convert Golang String to Byte Array

There are two ways to convert a string to a byte array in Golang. Using []byte(): It returns a new byte slice containing the same bytes. Using []rune(): It converts a string into a range of Unicode code points representing runes. Go byte is an unsigned 8-bit integer with an uint8 data type. Golang string is a sequence of variable characters where each character … Read more

Golang String: The Complete Guide

Golang Strings are different compared to other programming languages.  Golang Strings Golang string is a slice of bytes. Create a string by enclosing its contents inside ” “(double quotes) and not ‘ ‘(single quotes). The UTF-8 character can be defined in the memory size from 1 byte (ASCII compatible) to 4 bytes. Hence in Go, all … Read more

Golang I/O Functions: The Complete Guide on fmt

Package fmt implements the formatted I/O with functions analogous to C’s printf and scanf. If we want to print the string in the console, then we need to use fmt package in Golang. The format ‘verbs’ are derived from C language but are more straightforward. Before we start our Formatted I/O Functions example, Let’s start … Read more

Golang Template: The Complete Guide

Before we get into this, it’s a perfect time to have a swift look at struct, array, and slice in Golang, as these would be used quite a lot here. Golang Template The package template in Golang implements data-driven templates for generating textual output. To generate HTML output, see package html/template, which has the same … Read more

How to Convert Golang Slice to String

A slice is the data structure describing the contiguous section of an array stored separately from the slice variable itself. A slice is not an array. Instead, a slice represents a piece of an array. When you convert between the string and a byte slice (array), you get a new slice that contains the same … Read more

Golang Rune: The Complete Guide

ASCII stands for American Standard Code for Information Interchange, a character encoding standard for electronic communication. ASCII codes represent the text in computers, telecommunications equipment, and other devices. In the past years, we dealt with one character set, ASCII. It used 7 bits to represent 128 characters, including upper and lowercase English letters, digits, and … Read more