Difference between := and = operators in Go


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


Only = is the assignment operator.

:= is a part of the syntax of the Short variable declarations clause.

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

Answered By – zzzz

Answer Checked By – Clifford M. (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.