Hello World Golang
Hello World Golang
If you are using code from other packages, you list the
packages that you want to import. This allows you to The “fmt” package is being imported.
use code in your program that other people have
written. Packages are also sometimes referred to as
libraries.
If you are using code from other packages, you list the
packages that you want to import. This allows you to The “fmt” package is being imported.
use code in your program that other people have
written. Packages are also sometimes referred to as
libraries.
Code from the “fmt” package is being used. Println is a A parameter is the variable which is part of
function declared in the “fmt” package. For a function to be the func’s signature (func declaration). An
accessible to other packages, it must be Capitalized. This is argument is an expression used when
analogous to “public” in other languages. calling the func. source: modified from stackoverflow
The func main() is the entry point for your program; the first
code that will run. The package main can also have other
functions besides func main().
If you are using code from other packages, you list the
packages that you want to import. This allows you to The “fmt” package is being imported.
use code in your program that other people have
written. Packages are also sometimes referred to as
libraries.
Code from the “fmt” package is being used. Println is a A parameter is the variable which is part of
function declared in the “fmt” package. For a function to be the func’s signature (func declaration). An
accessible to other packages, it must be Capitalized. This is argument is an expression used when
analogous to “public” in other languages. calling the func. source: modified from stackoverflow
The func main() is the entry point for your program; the first
code that will run. The package main can also have other
functions besides func main().
… it doesn’t run.
my go workspace
Review
● code completion ● go run
● package main ○ go run gofiles...
○ func main() ● go build
■ entry point for your program ● go install
● packages, aka, libraries
● import
● functions
○ What makes a function accessible outside a
package
■ capitalization
● makes the function “public”
■ lowercase
● function restricted to package
● parameters vs arguments
● expressions vs statements
● variable, constant, literal
● cmd + click → takes you to source code
Review Questions
Package Main
● What is the purpose of package main in a go program?
● What function must package main contain?
● Can package main contain a function called func
blueSky() ?
funcs
What makes a func accessible outside a
package?
Parameters vs Arguments
● What is the difference between the two?
Expressions vs Statements
● What is the difference between the two?
Variable, Constant, Literal
● Define the three concepts above.
● Give an example of a literal from the “hello
world” example.
go run
● Build “hello go” in your editor
● use go run from the command line to make
your “hello go” program execute
go build
Go build does what when run on a folder
containing package main?
go build
Go build does what when run on a folder
containing a library package?
go install
Go install does what when run on a folder
containing package main?
go install
Go install does what when run on a folder
containing a library package?