HiveBrain v1.2.0
Get Started
← Back to all entries
gotchagoCritical

Difference between := and = operators in Go

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
operatorsandbetweendifference

Problem

What is the difference between the = and := operators, and what are the use cases for them? They both seem to be for an assignment?

Solution

Only = is the assignment operator.

:= is a part of the syntax of the short variable declaration clause.

👉 There are some rules though. See this other answer for more details.

Context

Stack Overflow Q#17891226, score: 282

Revisions (0)

No revisions yet.