13 Sep,2023 10:42 PM
Installed Go to my Macbook with
brew install go
To check whether Go is installed or not use
go
in the terminal and if it returns some commands that can be combined with go
Hello, World
- wrote the first
Hello World
program in Go
package main
import 'fmt'
func main() {
fmt.Println("Hello, World")
}
compiled the helloworld.go with
go build helloworld.go
which created an executable.executed with
./helloworld
We can compile and execute with a single command
go run helloworld.go
which 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)