Println() function and Strings em Go
In this post, you will learn how to work with the Println()
function and with strings so that you can use that same knowledge and thus evolve.
- the
Println()
function prints all its content on the command line and re-lines it (then we have thePrint()
function that doesn’t wrap lines and thePrintf()
function that puts values in certain places - of course we will use this last method during the series, and at this point I’ll explain better the working of this function -Printf()
); - a string is a set of characters (letters, numbers and/or symbols);
- all strings are initialized and ended with quotes (“string”);
- the escaped character is
\
and aims to make the character that follows part of the string. - you can increment (join the contents of the various strings) with a comma.
package main
import "fmt"
func main() {
fmt.Println("We are using the Println() function and I am a string.")
fmt.Println("Maria said that Miguel was \"sick\".") // Maria said that Miguel was "sick".
fmt.Println("Caffeine", "Algorithm") // Caffeine Algorithm
}
Don’t forget to watch the video and you can always read this post in Portuguese.