golang tutorial - golang tutorial - Go Program | Go Programming Language | First Program - golang - go programming language - google go - go language - go program - google language



Go Hello World Example

A Go program will have the following parts:

  • Package Declaration
  • Import Packages
  • Functions
  • Variables
  • Statements & Expressions
  • Comments

Sample code:

package main

import "fmt"

func main() {
/* Welcome to wikitechy. This is my first sample program. */
   fmt.Println("Hello, World! Welcome to Wikitechy")
}
click below button to copy the code. By - golang tutorial - team
go hello world

How to execute the Go Program:

  • Open a text editor and add the above-mentioned code.
  • Step 1 : Save the file as hello-world.go
  • Step 2 : Open a command prompt and go to the directory where you saved the file.
  • Step 3 : Type go run hello.go and press enter to run your code.
$ go run hello-world.go
click below button to copy the code. By - golang tutorial - team
  • Hello, World! Welcome to Wikitechy
$ go build hello-world.go
$ ls
click below button to copy the code. By - golang tutorial - team
  • hello-world hello-world.go
$ ./hello-world
click below button to copy the code. By - golang tutorial - team
  • Hello, World! Welcome to Wikitechy
  • Step 4 : You will get the output "Hello, World! Welcome to Wikitechy"

Related Searches to Go Program | Go Programming Language | First Program