Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Go comments

  • 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:

  1. 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 :

  2. 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 :

  3. 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:

The post Go comments appeared first on Prwatech.



This post first appeared on Learn Big Data Hadoop In Bangalore, please read the originial post: here

Subscribe to Learn Big Data Hadoop In Bangalore

Get updates delivered right to your inbox!

Thank you for your subscription

×