-
Single line comments
Single-line comments is start with two forward slashes ( // ).
Ex: // this is a single-line comment. // fmt.Println("This line does not execute")
-
Multi-line comments
Multi-line comments start with /* and ends with */ .
package main import ("fmt") func main() { /* The code below will print Hello Prwatech to the screen, and it is amazing */ fmt.Println("Hello Prwatech!") }
Output:
PS C:\GO_Language\datatype> go run float1.go Type: float32, value: 23.78 Type: float32, value: 3.4e+38
- Program to demonstrate the Example of print() function
package main // Main Function func main() { Name := "Sandeep" Age := 23 /* The code below will print Name and Age in a sentence to the screen, and it is amazing */ print(Name, " Age is ", Age, "Year") }
Output :
PS C:\GO_Language\datatype> go run float1.go Type: float32, value: 23.78 Type: float32, value: 3.4e+38
- Program to illustrate print function and multi-line comment.
package main import “fmt” func main() { book := "AI-ML Machine Learning " price := 21 /* The code below will print book and price in a sentence to the screen, and it is amazing */ print(book, " price is ", price) }
Output :
PS C:\GO_Language\datatype> go run float1.go Type: float32, value: 23.78 Type: float32, value: 3.4e+38
- Program to illustrate Scan() & print().
package main import "fmt" func main() { var name string var age int print("Enter Name :") fmt.Scan(&name) //scan the input value print("Enter Age :") fmt.Scan(&age) /* The code below will print Name and age in a sentence to the screen, and it is amazing */ fmt.Printf("My name is %s I am %d years old.", name, age) }
Output:
PS C:\GO_Language\datatype> go run float1.go Type: float32, value: 23.78 Type: float32, value: 3.4e+38