To print a value in Go, you can use the fmt package, which provides a set of functions for formatting and printing values. The most commonly used function is fmt.Println(), which prints a value to standard output followed by a newline character.
Here's an example:
main.go156 chars11 linesOutput:
main.go35 chars3 lines
In this example, we define two variables name and age, and print them using two separate fmt.Println() statements. The first statement uses string concatenation to include the value of name in the output, while the second statement uses multiple arguments to include the values of age and a string literal in the output. The fmt package automatically converts the values to strings and formats them according to the specified format.
gistlibby LogSnag