[go: up one dir, main page]

0% found this document useful (0 votes)
217 views1 page

Go by Example - Values

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
217 views1 page

Go by Example - Values

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Go by Example: Values https://gobyexample.

com/values

Go by Example: Values
Go has various value types including strings,
integers, floats, booleans, etc. Here are a few
basic examples.

package main

import "fmt"

func main() {

Strings, which can be added together with +. fmt.Println("go" + "lang")

Integers and floats. fmt.Println("1+1 =", 1+1)


fmt.Println("7.0/3.0 =", 7.0/3.0)

Booleans, with boolean operators as you’d expect. fmt.Println(true && false)


fmt.Println(true || false)
fmt.Println(!true)
}

$ go run values.go
golang
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false

Next example: Variables.

by Mark McGranaghan and Eli Bendersky | source | license

1 of 1 11/26/24, 23:21

You might also like