Found 1082 Articles for Go Programming

Check If the Rune is a Decimal Digit or not in Golang

Sabid Ansari
Updated on 07-Apr-2023 10:39:29

2K+ Views

A rune is a Unicode code point that is used as an alias for the int32 type in Go. It is frequently employed to denote a single character within a string. We occasionally need to determine whether a rune represents a decimal digit. This article will cover how to determine in Go whether a rune is a decimal digit. Using the unicode.IsDigit() Function To work with Unicode code points, Go has the unicode package, which includes functions. To determine whether a particular rune is a decimal digit or not, use the IsDigit() function of this package. A rune can be ... Read More

Check if the given slice is sorted in Golang

Sabid Ansari
Updated on 07-Apr-2023 10:38:54

310 Views

In Golang, it is important to know whether a slice is sorted or not, especially when working with algorithms that require sorted data. In this article, we will explore various methods to check if a given slice is sorted or not. Using a Loop to Check if the Slice is Sorted One way to check if a slice is sorted is to use a loop to compare adjacent elements in the slice. If the elements are in ascending order, then the slice is sorted. Here is an example code − Example package main import "fmt" func isSorted(s []int) ... Read More

Check if the given characters is present in Golang String

Sabid Ansari
Updated on 07-Apr-2023 10:37:10

3K+ Views

Presence of a specific character or group of characters in a string is a typical procedure when working with strings. Several methods for determining whether specific characters are present in a Golang string will be covered in this article. Using the strings.Contains() Function Using the built-in strings is the simplest approach to determine whether a character or substring is contained in a Golang string. the contains() function. A boolean value indicating whether the substring was discovered in the string is returned by this function, which requires two arguments: the string to search for and the substring to look for. Here ... Read More

Channel in Golang

Sabid Ansari
Updated on 07-Apr-2023 09:45:00

595 Views

Channels in Golang are useful for transferring data and coordinating the execution of goroutines. We will go over what channels are, how they operate, and how to use them successfully in Golang in this article. What are Channels? In Golang, channels are a means of data synchronisation and communication between goroutines. A channel primarily functions as a message queue that enables communication between goroutines. Without the requirement for explicit locking or synchronisation, channels offer a secure and effective method of data sharing between goroutines. How Channels Work Channels in Golang are implemented using the chan keyword. Channels can be created ... Read More

Calculating total number of Hours, Days, Minutes and Seconds between two dates in Golang

Sabid Ansari
Updated on 06-Apr-2023 12:04:04

640 Views

Calculating the total number of hours, days, minutes, and seconds between two dates is achievable in Golang. In this article, we'll go through how to accomplish this in Golang, along with the necessary libraries and sample code. Calculating the Total Number of Hours, Days, Minutes, and Seconds In Golang, we may utilise the time package to determine how many hours, days, minutes, and seconds are there between two dates. To modify dates and times, the time package offers a number of functions. The total number of hours, days, minutes, and seconds between two dates can be calculated in Go ... Read More

Buffered Channel in Golang

Sabid Ansari
Updated on 06-Apr-2023 12:03:31

442 Views

A buffered channel in Golang is a particular kind of channel that enables several values to be transmitted and received without blocking. In this post, we'll talk about buffered channels in Golang, their syntax, and some real-world uses. What is a Buffered Channel? In Golang, a channel type that can keep a predetermined number of values before blocking is known as a buffered channel. As long as there is space in the buffer, this permits sending and receiving numerous values without blocking. Any additional attempts to send data will be blocked after the buffer is filled until more room is ... Read More

Bitwise NOT Operator in Golang

Sabid Ansari
Updated on 06-Apr-2023 12:02:46

961 Views

The caret (^) character in Golang stands in for the bitwise NOT operator. By flipping 0s and 1s into 1s and 0s into 0s, this operator inverts the bits of an integer value. We'll talk about Golang's bitwise NOT operator and some real-world uses for it in this article. What is the Bitwise NOT Operator? The complement operator, also referred to as the bitwise NOT operator, is a unary operator that performs bit inversion on a single operand. For processing binary data in computer programmes, use this operator. The bitwise NOT operator flips all of the bits in an integer ... Read More

Bits Package in Golang

Sabid Ansari
Updated on 06-Apr-2023 12:01:25

412 Views

Bits package in Golang has functions for changing a binary number's individual bits. This package is very helpful in low-level applications like networking, cryptography, and bitwise operations. This post will go through the Golang bits package and show you how to utilise it in a real-world application. Introduction to the Bits Package The bits package offers tools for working with a binary number's constituent bits. The "BitArray" type, which represents a series of bits, is the main type in the bits package. An implementation of the "BitArray" type is a slice of "uint64" values, where each "uint64" value has ... Read More

Basics of JSON with GoLang

Sabid Ansari
Updated on 06-Apr-2023 11:59:21

295 Views

JSON has grown in popularity as a data format for transferring data across apps in recent years. JSON (JavaScript Object Notation) is a compact and simple-to-understand standard for exchanging data. It is widely used in server-to-server communication, mobile applications, and web applications. Its simplicity, concurrency, and scalability make GoLang a powerful programming language. The fundamentals of JSON with GoLang will be covered in this post. What is JSON? JSON is a simple, lightweight data exchange format that is simple for both people and robots to comprehend and generate. It is a completely language-independent text format that adheres to principles that ... Read More

Base64.DecodeString() Function in Golang With Examples

Sabid Ansari
Updated on 06-Apr-2023 11:56:45

842 Views

The base64 package in Golang provides several functions for encoding and decoding binary data in base64 format. DecodeString(), one of the most often used functions, decodes a base64-encoded string and returns the original binary data. We will thoroughly examine the DecodeString() method and discover how to decode base64-encoded data in Golang. We'll start by talking about the function's fundamental syntax and parameters before looking at some real-world applications. You ought to be able to utilise the DecodeString() function in your own Golang projects after reading this article. Basic Syntax of base64.DecodeString() The basic syntax of the DecodeString() function is as ... Read More

Advertisements