- 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)
574 Views
In Golang we can use functions like YearDay and Sub as well as arithmetic operation method to get the current day of the year out of 365. The current time is obtained using the Now function from the time package and YearDay() function is used to obtain the current day of the year out of 365. Method 1: Using YearDay and Sub Functions In this method, the number of days between the current date and start of the year are calculated using currentTime.Sub(start_of_year).Hours() / 24 as well as simple YearDay method. Syntax func Now() Time The Now() function ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
1K+ Views
In this article, we will learn to write a Go language program to convert the local time to GMT using internal functions like Now() Time, LoadLocation()and time.In(). Local time is the time of a particular region which is calculated using position of the sun at noon. The local time is obtained using Now function from the time package whereas the local time is converted to GMT using ln function from the time package. Syntax func Now() Time The Now() function is defined in time package. This function generates the current local time.To use this function, we have to first ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
268 Views
In this Golang article, we will write programs to add two dates. The dates are added using methods like Add(), AddDate(). There are different formats to represent a date. Here, the dates after addition will be represented using YY/MM/DD format. Syntax func (t Time) Sub(u Time) Duration The sub() function in Go is used to get the difference between two dates. In this function the first two parameters i.e., t and u are date values and this function returns the difference between two values in hours, minutes and seconds. time.Parse() This function belongs to the time package. It ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
591 Views
In Go programming language, a hash collection contains a hashmap which stores the values as key:value pairs for the efficient execution of the programs. In this article we will use two examples to get the hash collection values as an array. In the first example, we will create a slice and append the strings of map in that slice, in the second example we will hash the string and store it inside the map. In this way we will print the array. Syntax func make ([] type, size, capacity) The make function in go language is used to create ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
88 Views
In Golang we have inbuild function like ok idiom to check whether a given key exist in hash collection or not. Hashmap is a collection of values paired with key in hashmap collection. In this article, we will create a hashmap using the built-in function then we will use ok idiom that returns true false value to check whether a key exists in the map or not. In this way a success or failure statement will be printed. Algorithm Create a package main and declare fmt(format package) in the program where main produces executable codes and fmt helps in ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
271 Views
In golang we can merge two hash collection by using map function. A hashmap is present in hash collections. It stores key:value pairs. We can perform various operations on a hashmap like merging them. In this article we will merge two hashmaps using a method. In that method, we will create an additional map to store the merged key:value pairs. Then, the map will be printed on the terminal using fmt package. Algorithm Create a package main and declare fmt(format package) in the program where main produces executable codes and fmt helps in formatting input and output. ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
136 Views
In Go programming language, a hash collection contains a hashmap which holds values in form of key:value pairs. Here, in this particular program we will convert the map into array which is of fixed size and can be accessed via indexing. We will use two examples to execute the program. In the first example, we will use an index variable to add the values in the array and in the second example we will use an append method to add the values in the array. Syntax func make ([] type, size, capacity) The make function in go language is ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
1K+ Views
In Golang, a Hashmap is a part of hash collection and it stores values in the form of key:value pairs. In this articlewe will store items in the hash collection using two different examples. In the very first example the indexing will be used to store items in the map and in the second example item struct will be used to store items. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its size and capacity as arguments. Algorithm ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
588 Views
In golang we can check whether a given value exist in hash collection or not by simply using okidiom function or we can even create an if-else user-defined function to do the same. Hashmap is basically a collection of values paired with their keys in hash collection. In this article we are going to look over two different example to understand how we can use the above two techniques to check the given value in hash collection. Algorithm Create a package main and declare fmt(format package) in the program where main produces executable codes and fmt helps in formatting ... Read More
![Akhil Sharma](https://www.tutorialspoint.com/assets/profiles/525598/profile/60_3453735-1664185297.jpg)
111 Views
In golang, we can print the inverted hash collection using the inverted mapping method. Hashmap stored the data in pair of key:Value in hash collection and that reduces the execution time. In this article we are going to see two different example to understand how to create a golang program that will print an inverted hash collection. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its size and capacity as arguments. func len(v Type) int The len() function ... Read More