GO-Lang

<aside> <img src="/icons/code_red.svg" alt="/icons/code_red.svg" width="40px" />

First Install GO using .msi installer.

</aside>

<aside> <img src="/icons/code_red.svg" alt="/icons/code_red.svg" width="40px" />

go mod init <module_name>
// main.go file
package main

import "fmt"

func main() {
	fmt.Println("Hello world")
}
// hello world program
go run main.go

Types in GO,

image.png

image.png

Variables

**package main

import "fmt"

func main() {
	var username string = "niraj"
	fmt.Println(username)
	fmt.Printf("Type of the Variable is : %T \\n",username)

	var isLoggedIn bool  = true 
	fmt.Println(isLoggedIn)
	fmt.Printf("Type of the Variable is : %T \\n",isLoggedIn)
}**
package main
**import "fmt"

const LoginToken string = "sk,gbskgskjgbjksar" // Capital letter at start means its public
																						// to use**
func main(){
	var website = "Niraj salunke"
	fmt.Println(website)
	// Once a value of specific type is given, type cannot be modified later,
	// cannot assign website name as 3 (a integer) afterwards, can be assigned another
	// string
	
	
	//Also ther is no var style
	numberOfUser := 300; // this method is only allowed inside functions not outside
	fmt.Println(numberOfUser)
}

Input from user

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	fmt.Println("Enter ur age:- ")
	input, _ := reader.ReadString('\\n')
	fmt.Println("ok", input)
}