Home >Backend Development >Golang >The difference between '=' and ':=' in golang

The difference between '=' and ':=' in golang

王林
王林Original
2019-12-06 16:11:584538browse

The difference between '=' and ':=' in golang

In golang, "=" means assignment, and ":=" means declaring variables and assigning values.

For example:

// = 使用必须使用先var声明例如:
var a
a=100
//或
var b = 100
//或
var c int = 100

For example:

// := 是声明并赋值,并且系统自动推断类型,不需要var关键字
d := 100

Recommended related articles and tutorials: golang tutorial

The above is the detailed content of The difference between '=' and ':=' in golang. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn