Code review comments in Go programming (or any language) are critical feedback provided to developers during the code review process to ensure code quality, maintainability, and adherence to best practices. The goal of code reviews is to identify potential issues, improve code readability, and promote consistency across the codebase.
Common code in Go focus on several key aspects:
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 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
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
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
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