×

Go Tutorial

Go Basics

Go Variables

Go Literals

Go Type Handling

Go Operators

Go Decision Making

Go Loops

Go Functions

Go String

Go Arrays

Go Slices

Go Maps

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang Miscellaneous Operators

Last Updated : April 19, 2025

There are a few other special operators which are used in the Golang. Here is the list of some other/miscellaneous operators which are used in the Golang.

List of Miscellaneous Operators

Operator Description Example
x:=5
y:=3
Address Of (&) Returns the address of a variable. &x
Pointer to a variable (*) Returns the value of a pointer variable. *x
Receive (<-) This operator is used to receive a value from the channel. y := <-ch

Example of Miscellaneous Operators

The below Golang program is demonstrating the example of miscellaneous operators.

// Golang program demonstrate the
// example of assignment operators

package main

import "fmt"

func sum(s []int, c chan int) {
	sum := 0
	for _, v := range s {
		sum += v
	}
	c <- sum // send sum to c
}

func main() {
	x := 5

	// Address Of operator
	ptr := &x
	fmt.Println(*ptr)

	// Pointer to variable
	*ptr = 10
	fmt.Println(x)

	// Channel Example
	intslice := []int{7, 2, 8, -9, 4, 0}

	chnl := make(chan int)
	go sum(intslice[:len(intslice)/2], chnl)
	go sum(intslice[len(intslice)/2:], chnl)
	a, b := <-chnl, <-chnl // receive from chnl

	fmt.Println(a, b, a+b)
}

Output:

5
10
-5 17 12

Go Miscellaneous Operators Exercise

Select the correct option to complete each statement about miscellaneous operators in Go.

  1. The operator ___ is used to obtain the size of a variable in Go.
  2. The operator ___ is used to get the address of a variable in Go.
  3. The operator ___ is used to dereference a pointer in Go.

Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.