DEV Community

Cover image for Hello World in Go
vasanthkumar
vasanthkumar

Posted on • Edited on

Hello World in Go

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")
}
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode

GitHub commit link

Resources

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay