Increment in Go

Find this useful? Support us: Star on GitHub 6
Category: Number | Language: Go

In Go, to increment a number you can use the ++ operator. Here's an example:

package main

import "fmt"

func main() {
var num = 10
num++
fmt.Println(num) // Outputs: 11
}

In this example, we declare a variable num with an initial value of 10. Then we use the ++ operator to increment the value of num by 1. Finally, we print out the new value of num which is 11.