
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 33676 Articles for Programming

282 Views
Golang, also known as Go, is a popular open-source programming language known for its simplicity and concurrency. However, it lacked one important feature that other modern programming languages have, which is generics. Generics allow a programmer to write flexible, reusable code that works with different types without sacrificing type safety. In this article, we'll explore the introduction, syntax, and examples of generics in Golang. Introduction to Generics in Golang Generics are a way to write code that can work with any type, rather than being restricted to a specific type. In other words, generics allow you to write a function ... Read More

2K+ Views
Random numbers play an important role in many applications, from computer games to cryptography. Go has a built-in package called "math/rand" that provides a suite of functions to generate random numbers. In this article, we will explore how to use the "math/rand" package to generate random numbers in Go. Generating a Random Integer To generate a random integer, we can use the "Intn()" function from the "math/rand" package. The "Intn()" function takes an integer n as its argument and returns a random integer between 0 and n-1. Example package main import ( "fmt" ... Read More

3K+ Views
Universally Unique Identifier (UUID) is a 128-bit value that is used to uniquely identify objects or entities. UUID is widely used in computer systems for generating unique IDs for objects, documents, and data records. In Golang, we can generate UUID using the "github.com/google/uuid" package. Installing the "github.com/google/uuid" Package Before we can generate UUID in Golang, we need to install the "github.com/google/uuid" package. To install this package, run the following command in the terminal − go get github.com/google/uuid Generating UUID in Golang Once we have installed the "github.com/google/uuid" package, we can use the "uuid" package to generate UUIDs. Here's an ... Read More

1K+ Views
In Go, it is common to write functions that take interfaces as arguments or pointers to interfaces. This can be useful when you want to write generic code that works with any type that satisfies a particular interface. Functions That Take an Interface Type as Value In Go, interfaces are defined as a set of methods. If a type implements all the methods of an interface, then it is said to satisfy the interface. This means that the type can be used wherever the interface is expected. Here is an example of a function that takes an interface type as ... Read More

306 Views
Go is a modern programming language that offers a wide range of features for developing efficient and reliable software. One such feature is the ability to return multiple values from a function. In this article, we will explore how to use functions that return multiple values in Go. Introduction to Multiple Value Returns In Go, a function can return multiple values of different types. This feature is useful when you want to return more than one value from a function, such as returning both the result of a computation and an error value that indicates whether the computation was successful. ... Read More

4K+ Views
Functions are a first-class citizen in Go programming language, which means they can be treated as values and used as arguments or return values from other functions. This also extends to structs, where you can include a function as a field in a struct. In this article, we'll explore how to include a function as a field in a Golang structure and how to use it. Defining a Function as a Field in a Golang Structure To define a function as a field in a Golang structure, we first need to declare the type of the function using the type ... Read More

5K+ Views
When it comes to writing programs in Golang, understanding how to pass values to functions is essential. In this article, we will explore the basics of function arguments in Golang and learn how to pass values to functions effectively. What are Function Arguments? In Golang, a function argument is a value that is passed to a function when it is called. These values are used by the function to perform a task or calculation, and they can be of any data type, such as integers, strings, or booleans. How to pass Function Arguments in Golang? In Golang, function arguments are ... Read More

1K+ Views
The fmt package is one of the most commonly used packages in GoLang. It is used for formatting text and printing it to standard output or to a file. This package is part of the Go standard library, and it is included with every Go installation. In this article, we will explore the fmt package and learn how to use it effectively in our Go programs. What is the fmt Package? The fmt package is a built-in package in GoLang that provides functions for formatting text and printing it to the console or to a file. It includes a wide ... Read More

1K+ Views
In Golang, the flag package provides a way to parse command-line arguments. It allows us to define flags that can be set when running a program from the command line. The flag.Bool() function is used to define a boolean flag. It creates a new bool flag with the specified name, default value, and usage string. In this article, we will explore the flag.Bool() function with examples. Syntax The syntax of the flag.Bool() function is as follows − flag.Bool(name string, default bool, usage string) *bool Parameters name − A string that specifies the name of the flag. default − ... Read More

1K+ Views
DHT11 and DHT22 sensors are sensors that can be attached to a microcontroller on a breadboard and can measure the humidity and temperature of a place. The differences between these sensors are that DHT22 is more expensive, has better temperature reading ranges, and is more accurate. These sensors can be connected to microcontrollers such as ESP32 or Arduino and can be used by programs to read the values. In this article, using two different examples, the use of DHT11 and DHT22 Sensors is demonstrated using ESP32. The circuit is made using ESP32 microcontroller and DHT sensors in actual and on ... Read More