Go - Program Structure

Go - Program Structure : basic building squares of Go programming language.

Hello World Example

The accompanying rundown straightforward of Go :
  • Package Declaration
  • Import Packages
  • Functions
  • Variables
  • Statements and Expressions
  • Comments
Give us a chance to investigate straightforward code that may print the expressions "Hi World Welookups" −
package deal principal 

import "fmt" 

func principal()  

/* This is my first example application. */ 

fmt.Println("Hello, World Welookups!") 

Let us test the various parts of the above application :

The first line of the program pack chief characterizes the group name wherein this application need to lie.

func vital() is the essential capacity where this framework execution starts.

The ensuing line/*...*/is ignored by means of the compiler and it is there to include remarks inside the program.

Executing a Go Program

Give us a chance to talk about how to spare the supply code in a report, unite it, and at last execute this framework.
  • Open a printed substance manager and include the above-refered to code.

  • Save the archive as whats up.Pass

  • Open the order sparkle off.

  • Go to the catalog wherein you put away the file.

  • Type cross run hiya.Move and press enter to run your code.

  • If there aren't any oversights to your code, at that point you will see "Hello World!" imprinted on the screen.


$ go run howdy.Cross 

Hi, World Welookups!