Declare Functions in Golang

Create new folder named src. In src folder, create new file named main.go as below:

package main

import "fmt"

func main() {
	Hello()
	Sum(1, 2)
	Sub(10, 5)
}

func Hello() {
	fmt.Println("Hello World")
}

func Sum(a int, b int) {
	fmt.Println("Sum: ", (a + b))
}

func Sub(a, b int) {
	fmt.Println("Sub: ", (a - b))
}




Open Terminal windows in Visual Studio Code and run command line: go run main.go

Hello World
Sum: 3
Sub: 5