go EXERCISE

Check out the exercise and its solution here. EXERCISE Create a new library In it, create a function that returns the Go version Create a command and import your library Call your function that return
阅读全文

go 01-gopath

Where should you save your Go source code? Anywhere on my computer Under $GOPATH Under $GOPATH/src CORRECT What does $GOPATH mean? It's a file for Go runtime Stores Go source code files and compiled p
阅读全文

go 02-code-your-first-program

Which keyword below that you need use to define a package? package main func main() { } func package CORRECT fmt.Println import 1: func keyword is used to declare a new function. 2: That's right! pack
阅读全文

go 03-run-your-first-program

What is the difference between go build and go run? go run just compiles a program; whereas go build both compiles and runs it. go run both compiles and runs a program; whereas go build just compiles
阅读全文

go Cheatsheet: Write your First Go Program

Cheatsheet: Write your First Go Program Hi! For reference, you can store this cheatsheet after you take the lectures in this section. You can also print this cheatsheet and then follow the video lectu
阅读全文

go exercises

Print your name and your best friend's name using Println twice. Check out this exercise here. Say hello to yourself. Build your program using go build Send it to your friend S/he should use be using
阅读全文

go 01-packages-A

Where to store the source code files that belong to a package? Each file should go into a different directory In a single directory CORRECT Why a package clause is used in a Go source-code file? It's
阅读全文

go 03-scopes

What's a scope? Executable block of code The visibility of the declared names CORRECT Determines what to run package awesome import "fmt" var enabled bool func block() { var counter int fmt.Println(co
阅读全文

go 02-packages-B

Which one below is a correct package type in Go? Empty package Executable package CORRECT Transferrable package Librarian package Which package type go run can execute? Empty package Executable packag
阅读全文

go exercises

Use your own package Create a few Go files and call their functions from the main function. Try the scopes Learn the effects of scoping across packages. Rename imports Import the same package using a
阅读全文