13 Sep,2023 10:42 PM
Installed Go to my Macbook with
brew install goTo check whether Go is installed or not use
goin the terminal and if it returns some commands that can be combined with go
Hello, World
- wrote the first
Hello Worldprogram in Go
package main
import 'fmt'
func main() {
fmt.Println("Hello, World")
}
compiled the helloworld.go with
go build helloworld.gowhich created an executable.executed with
./helloworldWe can compile and execute with a single command
go run helloworld.gowhich didn't create any executable file.
Variables
variables in go can be declared in the following ways
var a int
var b bool
a = 15
b = true
var (
x int
y bool
)
x=100
y=false
m:=100
n:="New N"
var i,j int
i=1
j=2
Top comments (0)