Pointers in Go programming language or Golang is a variable which is used to store the memory address of another variable. Pointers in Golang are also termed as the special variables. The variables are used to store some data at a particular memory address in the system. The memory address is always found in hexadecimal format(starting with 0x like 0xFFAAF etc.).
In pointers, you are allowed to find the capacity of the pointer with the help of cap() function. This function is a built-in function returns the capacity of the pointer to array. In Go language, capacity defines the maximum number of elements stored in a pointer to array. This function is defined under builtin.
func cap(l Type) int
Here, the type of l is a pointer. Let us discuss this concept with the help of the examples:
Capacity of ptr1 : 7 Capacity of ptr2 : 5 Capacity of ptr3 : 8
Value of p = 200 Value of p = 300 Value of p = 400 Value of p = 500 Value of p = 600 Capacity of arr: 8 Capacity of p: 5
- How to find the length of the pointer in Golang?
- Pointer to a Struct in Golang
- Golang Pointer to an Array as Function Argument
- How to find the last index value of specified string in Golang?
- How to find the index value of specified string in Golang?
- Golang | How to find the index of rune in the string?
- How to find the first index value in slice of bytes in Golang?
- How to find the last index value in slice of bytes in Golang?
- How to find last index value of specified byte in slice of bytes in Golang?
- How to find the index value of any element in slice of bytes in Golang?
- How to find the last index value of any element in slice of bytes in Golang?
- Go Pointer to Pointer (Double Pointer)
- Zero value in Golang
- Structures in Golang
- Slices in Golang
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.