导航
×
   ❮   
HTML CSS JavaScript PHP Go ECMS

Go 运算符


Go 运算符

运算符用于对变量和值执行操作。

The + operator adds together two values, like in the example below

实例

package main
import ("fmt")

func main() {
  var a = 15 + 25
  fmt.Println(a)
}
亲自试一试 »

Although the + operator is often used to add together two values, it can also be used to add together a variable and a value, or a variable and another variable

实例

package main
import ("fmt")

func main() {
  var (
    sum1 = 100 + 50 // 150 (100 + 50)
    sum2 = sum1 + 250 // 400 (150 + 250)
    sum3 = sum2 + sum2 // 800 (400 + 400)
  )
  fmt.Println(sum3)
}
亲自试一试 »

Go divides the operators into the following groups


freew3c.com 中文网是独立运营的中文开发者学习平台,与 freew3c.com 无关联。提供的内容仅用于学习和测试,不保证内容的正确性。


Copyright @2020-2026 京ICP备888888号-8