diff --git a/01-get-started/Cheatsheet - Installation.pdf b/01-get-started/Cheatsheet - Installation.pdf new file mode 100644 index 0000000..572eff9 Binary files /dev/null and b/01-get-started/Cheatsheet - Installation.pdf differ diff --git a/01-get-started/README.md b/01-get-started/README.md index 58094c8..e52e1e1 100644 --- a/01-get-started/README.md +++ b/01-get-started/README.md @@ -1 +1,83 @@ -This section is in progress. I'm working hard to update the course all the time. Hold on! \ No newline at end of file +# CHEATSHEET: INSTALLATION + +👉 NOTE: For the missing steps you should continue clicking the Next buttons :) + +# 1 Install Visual Studio Code Editor + +1. Install it but don't open it yet. +2. Go to: [https://code.visualstudio.com](https://code.visualstudio.com) +3. Select your operating system (OS) and start downloading + 1. **Windows**: Run the installer. + 2. **OS X**: Uncompress the downloaded file and move it to your `~/Applications` directory. + +# 2 Install Git + +1. Go to: https://git-scm.com/downloads +2. Select your OS and start downloading +3. Run the installer +4. Select VSCode as the default editor + 1. **Windows**: + 1. Enable all the checkboxes + 2. Select: _"Use Git from the Windows Command Prompt"_ + 3. Encodings: Select: _"Checkout as is..." option._ + +# 3 Install Go + +1. Go to [https://golang.org/dl](https://golang.org/dl) +2. Select your OS and download +3. Start the installer + 1. **Windows:** + 1. Installs Go to `C:\Go` + 2. Your `$GOPATH` will be `C:\Go\src` + + 2. **OS X:** + 1. Installs Go to `~/go` + 2. Your `$GOPATH` will be `~/go/src` + +
+ +# 4 Configure VS Code + +1. Open VS Code; from the extensions tab at the left, search for "go" and install it +2. Close VS Code completely and open it up again + +3. Go to View menu; select **Command Palette** + 1. Or just press `cmd+shift+p` or `ctrl+shift+p` + 2. Type: `go install` + 3. Select _"Go: Install/Update Tools"_ + 4. Check all the checkboxes + +4. After it's done, open the **Command Palette** again + 1. Type: `shell` + 2. Select: _"Install 'code' command in PATH"_ + 1. **NOTE:** You don't have to do this if you're on Windows. + +5. **Additional Step for Windows Users: Git-Bash** + * In this course I'll be using bash commands. Bash is just a command-line interface used in OS X and Linux. It's one of the most popular command-line interfaces. So, if you want to use it too, instead of using the Windows default command-line, you can use git bash that you've installed. With git bash, you can type a command in command-line as you're on OS X or Linux. + + * If you don't want to use git bash, it's ok too. It depends on you. But note that, I'll be using bash commands mostly. Because, it allows more advanced commands as well. + + * So, to use git bash, follow these steps: + 1. Just search for git bash from the start bar + 2. Or, if there's one, click on the icon on your desktop + + 3. Also setup VS Code to use git-bash by default: + 1. Open VS Code + 2. Go to Command Palette + 1. Type: `terminal` + 2. Select: _"Terminal: Select Default Shell"_ + 3. And, Select: _"Git Bash"_ + + 4. **NOTE:** Normally, you can find your files under `c:\`, however, when you're using git bash, you'll find them under `/c/` directory. It's actually the very same directory, it's just a shortcut. + +## That's all! Enjoy! 🤩 + +
+ +> For more tutorials: [https://blog.learngoprogramming.com](https://blog.learngoprogramming.com) +> +> Copyright © 2018 Inanc Gumus +> +> Learn Go Programming Course +> +> [Click here to read the license.](https://creativecommons.org/licenses/by-nc-sa/4.0/) \ No newline at end of file diff --git a/02-write-your-first-program/Cheatsheet - Write Your First Go Program.pdf b/02-write-your-first-program/Cheatsheet - Write Your First Go Program.pdf new file mode 100644 index 0000000..beed0ba Binary files /dev/null and b/02-write-your-first-program/Cheatsheet - Write Your First Go Program.pdf differ diff --git a/02-write-your-first-program/Example Go Program - Annotated.pdf b/02-write-your-first-program/Example Go Program - Annotated.pdf new file mode 100644 index 0000000..577e846 Binary files /dev/null and b/02-write-your-first-program/Example Go Program - Annotated.pdf differ diff --git a/02-write-your-first-program/README.md b/02-write-your-first-program/README.md new file mode 100644 index 0000000..b032787 --- /dev/null +++ b/02-write-your-first-program/README.md @@ -0,0 +1,111 @@ +# 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 lectures in this section along with it. + +Enjoy! + +--- + +## COMMAND LINE COMMANDS: + +* Enter into a directory: `cd directoryPath` + +* **WINDOWS:** + + * List files in a directory: `dir` + +* **OS X & LINUXes:** + + * List files in a directory: `ls` + +--- + +## BUILDING & RUNNING PROGRAMS: + +* **Build a Go program:** + + * While inside a program directory, type: + * `go build` + +* **Run a Go program:** + + * While inside a program directory, type: + * `go run main.go` + +



+_See the next page..._ + +
+ +## WHAT IS $GOPATH? + +* _$GOPATH_ is an environment variable which points to a directory where the downloaded and your own Go files are stored. + + * **On Windows**, it's in: `%USERPROFILE%\go` + + * **On OS X & Linux**, it's in: `~/go` + + * **NOTE:** Never set your GOPATH manually. It's by default under your users directory. + +* **GOPATH has 3 directories:** + + * **src:** Contains the source files for your own or other downloaded packages. You can build and run programs while in a program directory under this directory. + + * **pkg:** Contains compiled package files. Go uses this to make the builds (compilation & linking) faster. + + * **bin:** Contains compiled and executable Go programs. When you call go install on a program directory, Go will put the executable under this folder. + + * _You might want to add this to your `PATH` environment variable if it's not there already._ + +--- + +## WHERE YOU SHOULD PUT YOUR SOURCE FILES? + +* `$GOPATH/src/github.com/yourUsername/programDirectory` + +* **Example:** + + * My github username is: inancgumus + + * So, I put all my programs under: `~/go/src/github.com/inancgumus/` + + * And, let's say that I've a program named hello, then I put it under this directory: `~/go/src/github.com/inancgumus/hello` + +



+_See the next page..._ + +
+ +## FIRST PROGRAM + +* Under, `~/go/src/github.com/inancgumus/hello`, create a `main.go` file. +* And add the following code to it. +* Then, run it like this: `go run main.go` + +```go +package main + +import "fmt" + +func main() { + fmt.Println("Hi! I want to be a Gopher!") +} +``` + +That's all! Enjoy! + +--- + +## NOTE: + +* BTW, There's a new *Go Modules* support which allows you to run your programs in any directory that you want. After the section ends, you'll also find an information about it. + +> For more tutorials: [https://blog.learngoprogramming.com](https://blog.learngoprogramming.com) +> +> Copyright © 2018 Inanc Gumus +> +> Learn Go Programming Course +> +> [Click here to read the license.](https://creativecommons.org/licenses/by-nc-sa/4.0/) \ No newline at end of file diff --git a/02-write-your-first-program/annotated-go-program-example.md b/02-write-your-first-program/annotated-go-program-example.md new file mode 100644 index 0000000..300c99e --- /dev/null +++ b/02-write-your-first-program/annotated-go-program-example.md @@ -0,0 +1,61 @@ +# Annotated Example Go Program + +```go +// package main is a special package +// it allows Go to create an executable file +package main + +/* +This is a multi-line comment. + +import keyword makes another package available + for this .go "file". + +import "fmt" lets you access fmt package's functionality + here in this file. +*/ +import "fmt" + +// "func main" is special. +// +// Go has to know where to start +// +// func main creates a starting point for Go +// +// After compiling the code, +// Go runtime will first run this function +func main() { + // after: import "fmt" + // Println function of "fmt" package becomes available + + // Look at what it looks like by typing in the console: + // godoc -src fmt Println + + // Println is just an exported function from + // "fmt" package + + // Exported = First Letter is uppercase + fmt.Println("Hello Gopher!") + + // Go cannot call Println function by itself. + // That's why you need to call it here. + // It only calls `func main` automatically. + + // ----- + + // Go supports Unicode characters in string literals + // And also in source-code: KÖSTEBEK! + // + // Because: Literal ~= Source Code +} +``` + +
+ +> For more tutorials: [https://blog.learngoprogramming.com](https://blog.learngoprogramming.com) +> +> Copyright © 2018 Inanc Gumus +> +> Learn Go Programming Course +> +> [Click here to read the license.](https://creativecommons.org/licenses/by-nc-sa/4.0/) \ No newline at end of file