Initial commit
This commit is contained in:
27
02-write-your-first-program/exercises/01/main.go
Normal file
27
02-write-your-first-program/exercises/01/main.go
Normal file
@ -0,0 +1,27 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE
|
||||
// Print your name and your best friend's name using
|
||||
// Println twice
|
||||
//
|
||||
// EXPECTED OUTPUT
|
||||
// YourName
|
||||
// YourBestFriendName
|
||||
//
|
||||
// BONUS
|
||||
// Use `go run` first.
|
||||
// And after that use `go build` and run your program.
|
||||
// ---------------------------------------------------------
|
||||
|
||||
func main() {
|
||||
// ?
|
||||
// ?
|
||||
}
|
20
02-write-your-first-program/exercises/01/solution/main.go
Normal file
20
02-write-your-first-program/exercises/01/solution/main.go
Normal file
@ -0,0 +1,20 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// go run main.go
|
||||
|
||||
// go build
|
||||
// ./solution
|
||||
|
||||
func main() {
|
||||
fmt.Println("Nikola")
|
||||
fmt.Println("Thomas")
|
||||
}
|
7
02-write-your-first-program/exercises/02/exercise.md
Normal file
7
02-write-your-first-program/exercises/02/exercise.md
Normal file
@ -0,0 +1,7 @@
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE
|
||||
// Print your GOPATH using `go env` tool
|
||||
//
|
||||
// EXPECTED OUTPUT
|
||||
// The physical folder path that is referenced by $GOPATH
|
||||
// ---------------------------------------------------------
|
@ -0,0 +1,3 @@
|
||||
You should type this:
|
||||
|
||||
go env GOPATH
|
39
02-write-your-first-program/exercises/all-exercises.md
Normal file
39
02-write-your-first-program/exercises/all-exercises.md
Normal file
@ -0,0 +1,39 @@
|
||||
1. **Run your own program? Say hello to yourself.**
|
||||
|
||||
1. Build your program using `go build`
|
||||
|
||||
2. And, send it to your friend
|
||||
(s/he should use be using the same operating system)
|
||||
(if you're using windows, then hers/his should be
|
||||
windows too)
|
||||
|
||||
3. And then send your program to a friend with a different
|
||||
operating system.
|
||||
|
||||
(So, you should compile your program for her operating system).
|
||||
|
||||
**For OSX, type:**
|
||||
GOOS=darwin GOARCH=386 go build
|
||||
|
||||
**For Windows:**
|
||||
GOOS=windows GOARCH=386 go build
|
||||
|
||||
**For Linux:**
|
||||
GOOS=linux GOARCH=arm GOARM=7 go build
|
||||
|
||||
**You can find the full list in here:**
|
||||
https://golang.org/doc/install/source#environment
|
||||
|
||||
2. **Call Print instead of Println** to see what happens.
|
||||
|
||||
3. **Call Println or Print with multiple values** by separating them using commas.
|
||||
|
||||
4. **Remove double quotes from string literals** and see what happens.
|
||||
|
||||
5. **Move the package and import statement** to the bottom of the file and see what happens.
|
||||
|
||||
6. **Read Go online documentation**. Take a quick look at the packages and read what they do. Look at their source-code by clicking on their titles.
|
||||
|
||||
You don't have to understand anything, just do it. This will warm you up for the upcoming lectures. https://golang.org/pkg
|
||||
|
||||
7. Also, **take a tour**: https://tour.golang.org/ See the language features. We're going to talk all about them soon.
|
Reference in New Issue
Block a user