Perbedaan function dan procedure adalah function mengembalikan suatu nilai, sementara procedure tidak. Prosedur hanya mengeksekusi bari kode saja.
Contoh code function
packagemainimport"fmt"funcadd(x int, y int) int {return x + y}funcmain() { fmt.Println(add(42, 13))}
Contoh code prosedur
packagemainimport ("fmt")funcmain() {Introduction("Adi", "programmer", 1, 23)}funcIntroduction(name, job string, experience, age int) { fmt.Printf(` Hello, Iam %s, I was an %s, I have %d experience and I am %d old. `, name, job, experience, age)}
Hello, Iam Adi,
I was an programmer,
I have 1 experience
and I am 23 old.