Key Concepts

Review core concepts you need to learn to master this subject

Go Comments

// one line comment /* this comment is on multiple lines and ends here */

Comments are useful for documentation in a Go file and are ignored by the compiler. There are two types of comments:

  • a single-lined comment is preceded by a double forward slash, //, and ends at the end of the line.
  • a multi-lined comment begins with /* followed by one or more lines of comments and ends with */
Learn Go: Introduction
Lesson 1 of 1
  1. 1
    Go, or Golang, is a language that was developed by Google for in-house software development, to make their software easier to write, maintain and build. Go has quickly become ve…
  2. 2
    Now we know what Go is for, let’s learn how to use the Go Compiler to compile a file into an executable. In our terminal, we type in go build followed by the name of our file and press Enter . I…
  3. 3
    Great, we were able to use the Go compiler to build an executable. We can run that executable as many times as we want. But what happens if we ever wanted to change our program? We would have to c…
  4. 4
    Now that we understand how to compile and run Go programs, let’s take a look at Go packages. Projects can contain many .go files, organized into packages. Each package is like a directory: .go fi…
  5. 5
    Now that we know how to declare & use Go packages, let’s look through the rest of the code: func main () { fmt.Println(“Hello World”) } #### main Function #### We use the func keyword to …
  6. 6
    Previously, we imported a single package, fmt. This package is useful but it is only one in a list of many included with Go. The standard packages are so useful that yo…
  7. 7
    Now we have completed the basics of using packages, let’s move on to comments. #### Before Commenting… “Don’t comment bad code — rewrite it.” — Brian W. Kernighan and P. J. Plaugher. Try to …
  8. 8
    There are many resources available to help us learn Go. ##### Go Doc ##### Go includes a program go doc for extracting and viewing documentation from .go files. For information about a package, u…
  9. 9
    Great job! We’ve just finished your first Go lesson! In this lesson we learned about: * What Go/Golang is & what its used for. * The Go compiler. * Go Packages, including the main for executable…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo