Join egghead, unlock knowledge.

Want more egghead?

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

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Getting Started with Hello World in Go

    Chris BiscardiChris Biscardi

    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
    Transcript

    Transcript

    Instructor: 00:00 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.

    00:18 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.

    Discuss

    Discuss