Go Language structure:
- Package Declaration: It is a mandatory statement, as Go programs run in packages. The main package is the entry point of the program.
- 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.
- Functions: Functions are the building blocks of Go programs. The main function is the entry point of the program, where execution starts.
- Variables: Variables are used to store data. In this example, we declare a variable ‘name’ and assign it the value “Go Developers”.
- Statements and Expressions: These are the instructions that perform actions. In this case, we use fmt.Println to print a message to the console.
- 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 */