🎁

12 Days of Baddass Courses sale! Get instant access to the entire egghead library of courses and lessons for 58% off.

Runs out in:
11 : 17 : 36 : 35
Join egghead, unlock knowledge.

Want more egghead? It's 58% off for a limited time only!

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock All Content for 40% Off
1×
Become a member
to unlock all features
Autoplay

    Getting Started with Hello World in Go

    Chris BiscardiChris Biscardi
    goGo

    We'll cover a small Golang program that prints a string to the terminal, showing how to set up an executable program, import a package, and build a binary.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: For our first Go program, we have a single file called main.go. Inside of main.go, we declare the package to be Main. This is the default for all executables. We import format because we're going to be printing a string later and we define a Main func. This is the function that will be called when we execute our executable.

    Finally, from the format package that we imported, we call print line with "Hello World." We can use Go Run to run our program. Also, since Go is a compiled language, we can run Go Build to build an executable. Now we have an additional file called Main, and when we run it, our program prints.