ARTIFICIAL INTELLIGENCE
AI Knowledge Base by Sunil Marella
Home Docs

Go Language structure:

  1. Package Declaration: It is a mandatory statement, as Go programs run in packages. The main package is the entry point of the program.
  2. Import Packages: This is where you import other packages that your program needs. In this case, we import the “fmt” package for formatted I/O.
  3. Functions: Functions are the building blocks of Go programs. The main function is the entry point of the program, where execution starts.
  4. Variables: Variables are used to store data. In this example, we declare a variable ‘name’ and assign it the value “Go Developers”.
  5. Statements and Expressions: These are the instructions that perform actions. In this case, we use fmt.Println to print a message to the console.
  6. Comments: Comments are used to explain the code and are ignored by the compiler. They can be single-line (//) or multi-line (/* * / ).

Hello World

package main

import "fmt"

func main() {
	fmt.Println("Hello Go")
}

Tokens in Go

Tokens in go: Tokens are individual keyword, symbol, varfiable or any thing For ex: fmt.Println(“Azure for”, name) - Contains 6 tokens which if fmt, . , Println, (, ), “Hello Go”

Comments

// single line comment

/* Multi line comments */