0% found this document useful (0 votes)
8 views

Go by Example - Hello World

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Go by Example - Hello World

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Go by Example: Hello World https://gobyexample.

com/hello-world

Go by Example: Hello World


Our first program will print the classic “hello package main
world” message. Here’s the full source code.

import "fmt"

func main() {
fmt.Println("hello world")
}

To run the program, put the code in hello-world.go $ go run hello-world.go


and use go run. hello world

Sometimes we’ll want to build our programs into $ go build hello-world.go


binaries. We can do this using go build. $ ls
hello-world hello-world.go

We can then execute the built binary directly. $ ./hello-world


hello world

Now that we can run and build basic Go


programs, let’s learn more about the language.

Next example: Values.

by Mark McGranaghan and Eli Bendersky | source | license

1 of 1 11/26/24, 23:21

You might also like